|
@@ -46,7 +46,7 @@
|
|
|
<template #slot-modify="{ scope }">
|
|
<template #slot-modify="{ scope }">
|
|
|
<el-button
|
|
<el-button
|
|
|
type="text"
|
|
type="text"
|
|
|
- @click.native.stop="replaceBtnFn(scope.row.id, scope.row.name)"
|
|
|
|
|
|
|
+ @click.native.stop="replaceBtnFn(scope.row.id)"
|
|
|
>修改</el-button
|
|
>修改</el-button
|
|
|
>
|
|
>
|
|
|
</template>
|
|
</template>
|
|
@@ -69,29 +69,34 @@
|
|
|
>
|
|
>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+
|
|
|
|
|
+ <template #slot-sync-btn>
|
|
|
|
|
+ <el-button type="primary" size="mini" @click="syncBtnFn({})">同步图片</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+
|
|
|
<template #slot-add-goods-btn>
|
|
<template #slot-add-goods-btn>
|
|
|
- <el-button type="primary" size="mini" @click="addBtn">添加</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" size="mini" @click="replaceBtnFn(0)">添加</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</x-crud>
|
|
</x-crud>
|
|
|
|
|
|
|
|
<!-- 新增弹窗 -->
|
|
<!-- 新增弹窗 -->
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
- :title="`${addOrModify == 1 ? '添加' : '修改'}花材`"
|
|
|
|
|
|
|
+ :title="`${currentItemId == 0 ? '添加' : '修改'}花材`"
|
|
|
:visible.sync="addDialog"
|
|
:visible.sync="addDialog"
|
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
|
width="600px"
|
|
width="600px"
|
|
|
>
|
|
>
|
|
|
<div class="ad-modal-content">
|
|
<div class="ad-modal-content">
|
|
|
<el-form
|
|
<el-form
|
|
|
- :model="adForm"
|
|
|
|
|
- :rules="adFormRules"
|
|
|
|
|
- ref="adForm"
|
|
|
|
|
|
|
+ :model="replaceForm"
|
|
|
|
|
+ :rules="replaceFormRules"
|
|
|
|
|
+ ref="replaceForm"
|
|
|
label-width="100px"
|
|
label-width="100px"
|
|
|
class="demo-form"
|
|
class="demo-form"
|
|
|
>
|
|
>
|
|
|
<el-form-item label="名称" prop="name">
|
|
<el-form-item label="名称" prop="name">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="adForm.name"
|
|
|
|
|
|
|
+ v-model="replaceForm.name"
|
|
|
placeholder="请输入名称"
|
|
placeholder="请输入名称"
|
|
|
size="small"
|
|
size="small"
|
|
|
></el-input>
|
|
></el-input>
|
|
@@ -99,20 +104,20 @@
|
|
|
|
|
|
|
|
<el-form-item label="别名" prop="alias">
|
|
<el-form-item label="别名" prop="alias">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="adForm.alias"
|
|
|
|
|
|
|
+ v-model="replaceForm.alias"
|
|
|
placeholder="请输入别名"
|
|
placeholder="请输入别名"
|
|
|
size="small"
|
|
size="small"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
- <el-form-item label="图片" prop="adImg">
|
|
|
|
|
- <cl-upload v-model="adForm.adImg" :success="uploadSuccess"></cl-upload>
|
|
|
|
|
|
|
+ <el-form-item label="图片" prop="cover">
|
|
|
|
|
+ <cl-upload v-model="replaceForm.cover" :success="uploadSuccess"></cl-upload>
|
|
|
<p style="font-size: 14px; color: #cccccc">建议上传图片比例 400X400</p>
|
|
<p style="font-size: 14px; color: #cccccc">建议上传图片比例 400X400</p>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="分类" prop="classId">
|
|
<el-form-item label="分类" prop="classId">
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="adForm.className"
|
|
|
|
|
|
|
+ v-model="replaceForm.className"
|
|
|
size="small"
|
|
size="small"
|
|
|
placeholder="请选择分类"
|
|
placeholder="请选择分类"
|
|
|
@change="selClassFn"
|
|
@change="selClassFn"
|
|
@@ -128,7 +133,7 @@
|
|
|
|
|
|
|
|
<el-form-item label="大单位" prop="bigUnitId">
|
|
<el-form-item label="大单位" prop="bigUnitId">
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="adForm.bigUnitName"
|
|
|
|
|
|
|
+ v-model="replaceForm.bigUnit"
|
|
|
size="small"
|
|
size="small"
|
|
|
placeholder="请选择单位"
|
|
placeholder="请选择单位"
|
|
|
@change="selBigUnitFn"
|
|
@change="selBigUnitFn"
|
|
@@ -142,9 +147,9 @@
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
- <el-form-item label="小单位" prop="samllUnitId">
|
|
|
|
|
|
|
+ <el-form-item label="小单位" prop="smallUnitId">
|
|
|
<el-select
|
|
<el-select
|
|
|
- v-model="adForm.samllUnitName"
|
|
|
|
|
|
|
+ v-model="replaceForm.smallUnit"
|
|
|
size="small"
|
|
size="small"
|
|
|
placeholder="请选择单位"
|
|
placeholder="请选择单位"
|
|
|
@change="selSmallUnitFn"
|
|
@change="selSmallUnitFn"
|
|
@@ -160,7 +165,7 @@
|
|
|
|
|
|
|
|
<el-form-item label="单位比" prop="ratio">
|
|
<el-form-item label="单位比" prop="ratio">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="adForm.ratio"
|
|
|
|
|
|
|
+ v-model="replaceForm.ratio"
|
|
|
placeholder="1扎=20支,请输入20"
|
|
placeholder="1扎=20支,请输入20"
|
|
|
size="small"
|
|
size="small"
|
|
|
></el-input>
|
|
></el-input>
|
|
@@ -168,36 +173,41 @@
|
|
|
|
|
|
|
|
<el-form-item label="库存预警" prop="stockWarning">
|
|
<el-form-item label="库存预警" prop="stockWarning">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="adForm.stockWarning"
|
|
|
|
|
- placeholder="请输入别名"
|
|
|
|
|
|
|
+ v-model="replaceForm.stockWarning"
|
|
|
|
|
+ placeholder="请输入数值"
|
|
|
size="small"
|
|
size="small"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
+ <el-form-item label="每扎重量" prop="weight">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="replaceForm.weight"
|
|
|
|
|
+ placeholder="请输入斤数"
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="每扎成本价" prop="cost">
|
|
<el-form-item label="每扎成本价" prop="cost">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="adForm.cost"
|
|
|
|
|
- placeholder="请输入别名"
|
|
|
|
|
|
|
+ v-model="replaceForm.cost"
|
|
|
|
|
+ placeholder="请输入成本价"
|
|
|
size="small"
|
|
size="small"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
<el-form-item label="每扎加价" prop="addPrice">
|
|
<el-form-item label="每扎加价" prop="addPrice">
|
|
|
<el-input
|
|
<el-input
|
|
|
- v-model="adForm.addPrice"
|
|
|
|
|
- placeholder="请输入价格"
|
|
|
|
|
|
|
+ v-model="replaceForm.addPrice"
|
|
|
|
|
+ placeholder="请输入加价"
|
|
|
size="small"
|
|
size="small"
|
|
|
></el-input>
|
|
></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
</el-form>
|
|
</el-form>
|
|
|
</div>
|
|
</div>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
<div slot="footer" class="dialog-footer">
|
|
|
<el-button size="small" @click="resetForm">取 消</el-button>
|
|
<el-button size="small" @click="resetForm">取 消</el-button>
|
|
|
- <el-button type="primary" size="small" @click="addFn">确认</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" size="small" @click="replaceConfirmFn">确认</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
</div>
|
|
</div>
|
|
@@ -226,65 +236,84 @@ export default {
|
|
|
},
|
|
},
|
|
|
classId: 0,
|
|
classId: 0,
|
|
|
addDialog: false,
|
|
addDialog: false,
|
|
|
- adForm: {
|
|
|
|
|
|
|
+ replaceForm: {
|
|
|
name: '',
|
|
name: '',
|
|
|
alias: '',
|
|
alias: '',
|
|
|
classId: '',
|
|
classId: '',
|
|
|
className: '',
|
|
className: '',
|
|
|
- adImg: '',
|
|
|
|
|
- bigUnitName: '',
|
|
|
|
|
|
|
+ cover: '',
|
|
|
bigUnitId: '',
|
|
bigUnitId: '',
|
|
|
- smallUnitName: '',
|
|
|
|
|
|
|
+ bigUnit: '',
|
|
|
smallUnitId: '',
|
|
smallUnitId: '',
|
|
|
- stockWarning:'',
|
|
|
|
|
- cost:'',
|
|
|
|
|
- addPrice:''
|
|
|
|
|
|
|
+ smallUnit: '',
|
|
|
|
|
+ stockWarning:'',
|
|
|
|
|
+ cost:'',
|
|
|
|
|
+ addPrice:'',
|
|
|
|
|
+ weight:'',
|
|
|
|
|
+ ratio:''
|
|
|
},
|
|
},
|
|
|
addOrModify: 1,
|
|
addOrModify: 1,
|
|
|
- adFormRules: {
|
|
|
|
|
|
|
+ replaceFormRules: {
|
|
|
name: {
|
|
name: {
|
|
|
required: true,
|
|
required: true,
|
|
|
- message: '广告图名称不能为空',
|
|
|
|
|
|
|
+ message: '名称不能为空',
|
|
|
},
|
|
},
|
|
|
- adImg: {
|
|
|
|
|
|
|
+ cover: {
|
|
|
required: true,
|
|
required: true,
|
|
|
- message: '广告图片不能为空',
|
|
|
|
|
|
|
+ message: '图片不能为空',
|
|
|
},
|
|
},
|
|
|
- style: {
|
|
|
|
|
- validator: (rule, value, callback) => {
|
|
|
|
|
- const { url, style } = this.adForm;
|
|
|
|
|
- if (style == '0') {
|
|
|
|
|
- if (!url) {
|
|
|
|
|
- //return callback(new Error('链接不能为空'));
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- if (!this.goodsData.id) {
|
|
|
|
|
- return callback(new Error('请选择商品'));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- callback();
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ classId: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请选择分类',
|
|
|
|
|
+ },
|
|
|
|
|
+ bigUnit: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请选择大单位',
|
|
|
|
|
+ },
|
|
|
|
|
+ smallUnit: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '请选择小单位',
|
|
|
|
|
+ },
|
|
|
|
|
+ ratio: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '比例不能为空',
|
|
|
|
|
+ },
|
|
|
|
|
+ stockWarning: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '最低库存不能为空',
|
|
|
|
|
+ },
|
|
|
|
|
+ cost: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '运费不能为空',
|
|
|
|
|
+ },
|
|
|
|
|
+ addPrice: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '加价不能为空',
|
|
|
},
|
|
},
|
|
|
|
|
+ weight: {
|
|
|
|
|
+ required: true,
|
|
|
|
|
+ message: '重量不能为空',
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
//分类列表
|
|
//分类列表
|
|
|
itemClassList: [],
|
|
itemClassList: [],
|
|
|
unitList: [],
|
|
unitList: [],
|
|
|
|
|
+ currentItemId: 0
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
computed: {},
|
|
computed: {},
|
|
|
methods: {
|
|
methods: {
|
|
|
selClassFn(val) {
|
|
selClassFn(val) {
|
|
|
let index = this.itemClassList.findIndex((e) => e.name == val);
|
|
let index = this.itemClassList.findIndex((e) => e.name == val);
|
|
|
- this.adForm.classId = this.itemClassList[index].id;
|
|
|
|
|
|
|
+ this.replaceForm.classId = this.itemClassList[index].id;
|
|
|
},
|
|
},
|
|
|
selBigUnitFn(val) {
|
|
selBigUnitFn(val) {
|
|
|
let index = this.unitList.findIndex((e) => e.name == val);
|
|
let index = this.unitList.findIndex((e) => e.name == val);
|
|
|
- this.adForm.bigUnitId = this.unitList[index].id;
|
|
|
|
|
|
|
+ this.replaceForm.bigUnit = this.unitList[index].id;
|
|
|
},
|
|
},
|
|
|
selSmallUnitFn(val) {
|
|
selSmallUnitFn(val) {
|
|
|
let index = this.unitList.findIndex((e) => e.name == val);
|
|
let index = this.unitList.findIndex((e) => e.name == val);
|
|
|
- this.adForm.smallUnitId = this.unitList[index].id;
|
|
|
|
|
|
|
+ this.replaceForm.smallUnit = this.unitList[index].id;
|
|
|
},
|
|
},
|
|
|
getAllClass() {
|
|
getAllClass() {
|
|
|
if (!this.$util.isEmpty(this.itemClassList)) {
|
|
if (!this.$util.isEmpty(this.itemClassList)) {
|
|
@@ -303,47 +332,33 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
uploadSuccess() {
|
|
uploadSuccess() {
|
|
|
- this.$refs['adForm'].validateField('adImg');
|
|
|
|
|
|
|
+ this.$refs['replaceForm'].validateField('cover');
|
|
|
},
|
|
},
|
|
|
- addBtn() {
|
|
|
|
|
|
|
+ replaceBtnFn(id) {
|
|
|
this.getAllClass()
|
|
this.getAllClass()
|
|
|
this.getAllUnit()
|
|
this.getAllUnit()
|
|
|
this.addDialog = true
|
|
this.addDialog = true
|
|
|
- this.adForm = {
|
|
|
|
|
- name: '',
|
|
|
|
|
- alias: '',
|
|
|
|
|
- adImg: '',
|
|
|
|
|
- bigUnitName: '',
|
|
|
|
|
- bigUnitId: '',
|
|
|
|
|
- smallUnitName: '',
|
|
|
|
|
- smallUnitId: '',
|
|
|
|
|
- stockWarning:'',
|
|
|
|
|
- cost:'',
|
|
|
|
|
- addPrice:''
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- selGoodsConfirmFn(item) {
|
|
|
|
|
- let param = [];
|
|
|
|
|
- item.forEach((value) => {
|
|
|
|
|
- let newObj = {};
|
|
|
|
|
- newObj.itemId = value.id;
|
|
|
|
|
- newObj.classId = this.classId;
|
|
|
|
|
- newObj.cost = value.cost;
|
|
|
|
|
- newObj.addPrice = value.addPrice;
|
|
|
|
|
- newObj.stockWarning = value.stockWarning;
|
|
|
|
|
- param.push(newObj);
|
|
|
|
|
- });
|
|
|
|
|
- param = JSON.stringify(param);
|
|
|
|
|
- console.log(param);
|
|
|
|
|
- this.$service.item
|
|
|
|
|
- .batchAdd({ data: param })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
- this.$message.success('操作成功!');
|
|
|
|
|
- this.$router.go(0);
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {
|
|
|
|
|
- console.log(err);
|
|
|
|
|
|
|
+ this.currentItemId = id
|
|
|
|
|
+ if(id == 0){
|
|
|
|
|
+ this.replaceForm = {
|
|
|
|
|
+ name: '',
|
|
|
|
|
+ alias: '',
|
|
|
|
|
+ cover: '',
|
|
|
|
|
+ bigUnitId: '',
|
|
|
|
|
+ bigUnit: '',
|
|
|
|
|
+ smallUnitId: '',
|
|
|
|
|
+ smallUnit: '',
|
|
|
|
|
+ stockWarning:'',
|
|
|
|
|
+ cost:'',
|
|
|
|
|
+ addPrice:'',
|
|
|
|
|
+ weight:'',
|
|
|
|
|
+ ratio:''
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ this.$service.item.getDetail({id:id}).then(async res => {
|
|
|
|
|
+ this.replaceForm = res
|
|
|
});
|
|
});
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
tabClick(tab, e) {
|
|
tabClick(tab, e) {
|
|
|
this.app.refresh({ classId: this.classId });
|
|
this.app.refresh({ classId: this.classId });
|
|
@@ -394,6 +409,24 @@ export default {
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
'min-width': 100,
|
|
'min-width': 100,
|
|
|
},
|
|
},
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'weight',
|
|
|
|
|
+ label: '重量',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ 'min-width': 100,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'bigUnit',
|
|
|
|
|
+ label: '大单位',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ minWidth: 100,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ prop: 'smallUnit',
|
|
|
|
|
+ label: '小单位',
|
|
|
|
|
+ align: 'center',
|
|
|
|
|
+ minWidth: 100,
|
|
|
|
|
+ },
|
|
|
{
|
|
{
|
|
|
prop: 'inTurn',
|
|
prop: 'inTurn',
|
|
|
label: '排序',
|
|
label: '排序',
|
|
@@ -410,7 +443,7 @@ export default {
|
|
|
op: {
|
|
op: {
|
|
|
visible: true,
|
|
visible: true,
|
|
|
props: {
|
|
props: {
|
|
|
- width: 300,
|
|
|
|
|
|
|
+ width: 250,
|
|
|
align: 'center',
|
|
align: 'center',
|
|
|
fixed: 'right',
|
|
fixed: 'right',
|
|
|
label: '操作',
|
|
label: '操作',
|
|
@@ -430,7 +463,7 @@ export default {
|
|
|
})
|
|
})
|
|
|
.set('layout', [
|
|
.set('layout', [
|
|
|
['slot-tabs'],
|
|
['slot-tabs'],
|
|
|
- ['flex1', 'slot-add-goods-btn', 'refresh-btn'],
|
|
|
|
|
|
|
+ ['slot-sync-btn', 'flex1', 'slot-add-goods-btn', 'refresh-btn'],
|
|
|
['data-table'],
|
|
['data-table'],
|
|
|
['flex1', 'pagination'],
|
|
['flex1', 'pagination'],
|
|
|
])
|
|
])
|
|
@@ -466,30 +499,30 @@ export default {
|
|
|
},
|
|
},
|
|
|
resetForm() {
|
|
resetForm() {
|
|
|
this.goodsData = {};
|
|
this.goodsData = {};
|
|
|
- this.$refs['adForm'].resetFields();
|
|
|
|
|
|
|
+ this.$refs['replaceForm'].resetFields();
|
|
|
this.addDialog = false;
|
|
this.addDialog = false;
|
|
|
},
|
|
},
|
|
|
- addFn() {
|
|
|
|
|
- this.$refs.adForm.validate((valid) => {
|
|
|
|
|
|
|
+ replaceConfirmFn() {
|
|
|
|
|
+ this.$refs.replaceForm.validate((valid) => {
|
|
|
if (valid) {
|
|
if (valid) {
|
|
|
- let form = JSON.parse(JSON.stringify(this.adForm));
|
|
|
|
|
- let host = null;
|
|
|
|
|
- if (this.addOrModify == 1) {
|
|
|
|
|
|
|
+ let form = JSON.parse(JSON.stringify(this.replaceForm))
|
|
|
|
|
+ let host = null
|
|
|
|
|
+ if (this.currentItemId == 0) {
|
|
|
host = () => {
|
|
host = () => {
|
|
|
- return this.$service.ad.add(form);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ return this.$service.item.itemAdd(form)
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
host = () => {
|
|
host = () => {
|
|
|
- return this.$service.ad.update({
|
|
|
|
|
|
|
+ return this.$service.item.update({
|
|
|
id: this.modifyData.id,
|
|
id: this.modifyData.id,
|
|
|
...form,
|
|
...form,
|
|
|
- });
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
host().then((res) => {
|
|
host().then((res) => {
|
|
|
- this.$message.success('操作成功!');
|
|
|
|
|
- this.resetForm();
|
|
|
|
|
- this.app.refresh({ type: this.tabIndex });
|
|
|
|
|
|
|
+ this.$message.success('操作成功!')
|
|
|
|
|
+ this.resetForm()
|
|
|
|
|
+ this.app.refresh({ classId: this.classId })
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|