学习很差啦 2022-09-22 09:14:05 +08:00
commit 72c64f017f
3 changed files with 42 additions and 36 deletions

View File

@ -377,9 +377,9 @@ export default {
this.loading = true; this.loading = true;
getGoodsListData(this.searchForm).then((res) => { getGoodsListData(this.searchForm).then((res) => {
this.loading = false; this.loading = false;
if (res.records) { if (res.success) {
this.data = res.records; this.data = res.result.records;
this.total = res.total; this.total = res.result.total;
} }
}); });
}, },

View File

@ -254,9 +254,9 @@ export default {
this.searchForm.authFlag = 0; this.searchForm.authFlag = 0;
getAuthGoodsListData(this.searchForm).then((res) => { getAuthGoodsListData(this.searchForm).then((res) => {
this.loading = false; this.loading = false;
if (res.records) { if (res.success) {
this.data = res.records; this.data = res.result.records;
this.total = res.total; this.total = res.result.total;
} }
}); });
}, },

View File

@ -18,7 +18,9 @@
style="width: 200px" style="width: 200px"
/> />
</Form-item> </Form-item>
<Button @click="handleSearch" type="primary" class="search-btn">搜索</Button> <Button @click="handleSearch" type="primary" class="search-btn"
>搜索</Button
>
</Form> </Form>
<Row class="operation padding-row"> <Row class="operation padding-row">
<Button @click="add" type="primary">添加</Button> <Button @click="add" type="primary">添加</Button>
@ -56,10 +58,14 @@
:mask-closable="false" :mask-closable="false"
:width="500" :width="500"
> >
<Form ref="form" :model="form" :label-width="100" <Form ref="form" :model="form" :label-width="100" :rules="formValidate">
:rules="formValidate">
<FormItem label="规格名称" prop="specName"> <FormItem label="规格名称" prop="specName">
<Input v-model="form.specName" maxlength="30" clearable style="width: 100%"/> <Input
v-model="form.specName"
maxlength="30"
clearable
style="width: 100%"
/>
</FormItem> </FormItem>
<FormItem label="规格值" prop="specValue"> <FormItem label="规格值" prop="specValue">
<Select <Select
@ -72,28 +78,30 @@
popper-class="spec-values-popper" popper-class="spec-values-popper"
style="width: 100%; text-align: left; margin-right: 10px" style="width: 100%; text-align: left; margin-right: 10px"
> >
<Option v-for="item in specValue" :value="item" :label="item" :key="item"> <Option
v-for="item in specValue"
:value="item"
:label="item"
:key="item"
>
</Option> </Option>
</Select> </Select>
</FormItem> </FormItem>
</Form> </Form>
<div slot="footer"> <div slot="footer">
<Button type="text" @click="modalVisible = false">取消</Button> <Button type="text" @click="modalVisible = false">取消</Button>
<Button type="primary" :loading="submitLoading" @click="saveSpec"></Button> <Button type="primary" :loading="submitLoading" @click="saveSpec"
>提交</Button
>
</div> </div>
</Modal> </Modal>
</div> </div>
</template> </template>
<script> <script>
import { import { getSpecListData, insertSpec, updateSpec, delSpec } from "@/api/goods";
getSpecListData,
insertSpec,
updateSpec,
delSpec
} from "@/api/goods";
import {regular} from "@/utils"; import { regular } from "@/utils";
export default { export default {
name: "spec", name: "spec",
components: {}, components: {},
@ -116,10 +124,7 @@ export default {
regular.REQUIRED, regular.REQUIRED,
// regular.VARCHAR20 // regular.VARCHAR20
], ],
specValue: [ specValue: [regular.REQUIRED, regular.VARCHAR255],
regular.REQUIRED,
regular.VARCHAR255
],
}, },
form: { form: {
// //
@ -147,7 +152,7 @@ export default {
title: "规格值", title: "规格值",
key: "specValue", key: "specValue",
minWidth: 250, minWidth: 250,
tooltip: true tooltip: true,
}, },
{ {
title: "操作", title: "操作",
@ -157,7 +162,6 @@ export default {
width: 250, width: 250,
render: (h, params) => { render: (h, params) => {
return h("div", [ return h("div", [
h( h(
"Button", "Button",
{ {
@ -253,8 +257,10 @@ export default {
// //
getSpecListData(this.searchForm).then((res) => { getSpecListData(this.searchForm).then((res) => {
this.loading = false; this.loading = false;
this.data = res.records; if (res.success) {
this.total = res.total; this.data = res.result.records;
this.total = res.result.total;
}
}); });
this.loading = false; this.loading = false;
}, },
@ -264,10 +270,10 @@ export default {
if (valid) { if (valid) {
this.submitLoading = true; this.submitLoading = true;
if (this.modalType === 0) { if (this.modalType === 0) {
if(this.data.find(item=>item.specName == this.form.specName)){ if (this.data.find((item) => item.specName == this.form.specName)) {
this.$Message.error('请勿添加重复规格名称!') this.$Message.error("请勿添加重复规格名称!");
this.submitLoading = false this.submitLoading = false;
return return;
} }
// id // id
delete this.form.id; delete this.form.id;
@ -298,7 +304,7 @@ export default {
this.modalType = 0; this.modalType = 0;
this.modalTitle = "添加"; this.modalTitle = "添加";
this.$refs.form.resetFields(); this.$refs.form.resetFields();
this.specValue = ''; this.specValue = "";
delete this.form.id; delete this.form.id;
this.modalVisible = true; this.modalVisible = true;
}, },
@ -319,9 +325,9 @@ export default {
this.form.specValue = v.specValue; this.form.specValue = v.specValue;
if (localVal && localVal.indexOf("," > 0)) { if (localVal && localVal.indexOf("," > 0)) {
this.form.specValue = localVal.split(",") this.form.specValue = localVal.split(",");
this.specValue = this.form.specValue this.specValue = this.form.specValue;
this.$set(this, 'specValue', this.form.specValue) this.$set(this, "specValue", this.form.specValue);
} else { } else {
this.specValue = []; this.specValue = [];
} }
@ -365,7 +371,7 @@ export default {
if (res.success) { if (res.success) {
this.$Message.success("删除成功"); this.$Message.success("删除成功");
this.clearSelectAll(); this.clearSelectAll();
this.searchForm.pageNumber = 1 this.searchForm.pageNumber = 1;
this.getDataList(); this.getDataList();
} }
}); });