|
|
@@ -7,6 +7,11 @@
|
|
|
</el-tab-pane>
|
|
|
</el-tabs>
|
|
|
</template>
|
|
|
+
|
|
|
+ <template #slot-add-cp-btn>
|
|
|
+ <el-button type="primary" size="mini" @click="replaceCpFn(0)">添加</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
<template #table-column-cover="{ scope }">
|
|
|
<cl-avatar shape="square" :size="36" :src="scope.row.cover" :style="{ margin: 'auto' }" >
|
|
|
</cl-avatar>
|
|
|
@@ -56,8 +61,34 @@
|
|
|
</el-popover>
|
|
|
</template>
|
|
|
</template>
|
|
|
-
|
|
|
</x-crud>
|
|
|
+
|
|
|
+ <el-dialog :title="`${currentCpId == 0 ? '添加' : '修改'}产品`" :visible.sync="replaceCpPop" :close-on-click-modal="false" width="500px" >
|
|
|
+ <div class="ad-modal-content">
|
|
|
+ <el-form :model="replaceForm" :rules="replaceRule" ref="replaceForm" label-width="100px" class="demo-form" >
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="replaceForm.name" placeholder="请输入名称" size="small" ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="图片" prop="cover">
|
|
|
+ <cl-upload v-model="replaceForm.cover" :success="uploadCpImg"></cl-upload>
|
|
|
+ <p style="font-size: 14px; color: #cccccc">建议上传1:1图片</p>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="分类" prop="classId">
|
|
|
+ <el-select v-model="replaceForm.className" size="small" placeholder="请选择分类" @change="replaceSetClass" >
|
|
|
+ <el-option v-for="(item, index) in cpClassData" :key="index" :value="item.name" >{{ item.name }}</el-option >
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序" prop="inTurn">
|
|
|
+ <el-input v-model="replaceForm.inTurn" placeholder="请输入数值" size="small" ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button size="small" @click="resetForm">取消</el-button>
|
|
|
+ <el-button type="primary" size="small" @click="replaceConfirmFn">确认</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
@@ -82,15 +113,104 @@ export default {
|
|
|
status: false,
|
|
|
},
|
|
|
catId: '',
|
|
|
- addDialog: false,
|
|
|
itemClassList: [],
|
|
|
unitList: [],
|
|
|
- currentItemId: 0,
|
|
|
- classStyle:"-1",//-1全部 0未归类
|
|
|
+ //-1全部 0未归类
|
|
|
+ classStyle:"-1",
|
|
|
+ replaceCpPop:false,
|
|
|
+ currentCpId:0,
|
|
|
+ replaceForm: {
|
|
|
+ name: '',
|
|
|
+ py:'',
|
|
|
+ classId: '',
|
|
|
+ className: '',
|
|
|
+ cover: '',
|
|
|
+ inTurn:100,
|
|
|
+ },
|
|
|
+ replaceRule: {
|
|
|
+ name: {
|
|
|
+ required: true,
|
|
|
+ message: '名称不能为空',
|
|
|
+ },
|
|
|
+ cover: {
|
|
|
+ required: true,
|
|
|
+ message: '图片不能为空',
|
|
|
+ },
|
|
|
+ classId: {
|
|
|
+ required: true,
|
|
|
+ message: '请选择分类',
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
+ replaceSetClass(e) {
|
|
|
+ console.log(e)
|
|
|
+ },
|
|
|
+ uploadCpImg() {
|
|
|
+ this.$refs['replaceForm'].validateField('cover');
|
|
|
+ },
|
|
|
+ resetForm() {
|
|
|
+ this.$refs['replaceForm'].resetFields();
|
|
|
+ this.replaceCpPop = false;
|
|
|
+ },
|
|
|
+ replaceCpFn(id){
|
|
|
+ this.replaceCpPop = true
|
|
|
+ this.currentCpId = id
|
|
|
+ if(id == 0){
|
|
|
+ this.replaceRule = {};
|
|
|
+ this.replaceForm = {
|
|
|
+ name: '',
|
|
|
+ classId:'',
|
|
|
+ cover: '',
|
|
|
+ className:'',
|
|
|
+ inTurn:100
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.$service.item.getDetail({id:id}).then(async res => {
|
|
|
+ this.replaceRule = {
|
|
|
+ name: {
|
|
|
+ required: true,
|
|
|
+ message: '名称不能为空',
|
|
|
+ },
|
|
|
+ cover: {
|
|
|
+ required: true,
|
|
|
+ message: '图片不能为空',
|
|
|
+ },
|
|
|
+ classId: {
|
|
|
+ required: true,
|
|
|
+ message: '请选择分类',
|
|
|
+ },
|
|
|
+ inTurn:{
|
|
|
+ required:true,
|
|
|
+ message:'排序不能为空',
|
|
|
+ }
|
|
|
+ };
|
|
|
+ let index = this.itemClassList.findIndex((e) => e.id == res.classId)
|
|
|
+ this.replaceForm.name = res.name
|
|
|
+ this.replaceForm.cover = res.cover
|
|
|
+ this.replaceForm.bigUnitId = res.bigUnitId
|
|
|
+ this.replaceForm.bigUnit = res.bigUnit
|
|
|
+ this.replaceForm.smallUnitId = res.smallUnitId
|
|
|
+ this.replaceForm.smallUnit = res.smallUnit
|
|
|
+ this.replaceForm.stockWarning = res.stockWarning
|
|
|
+ this.replaceForm.weight = res.weight
|
|
|
+ this.replaceForm.inTurn = res.inTurn
|
|
|
+ this.replaceForm.ratio = res.ratio
|
|
|
+ this.replaceForm.ratioType = res.ratioType
|
|
|
+ if(res.ratioType == 0){
|
|
|
+ this.replaceForm.ratioTypeName = '固定比例'
|
|
|
+ }else{
|
|
|
+ this.replaceForm.ratioTypeName = '模糊比例'
|
|
|
+ }
|
|
|
+ this.replaceForm.classId = res.classId
|
|
|
+ this.replaceForm.py = res.py
|
|
|
+ this.replaceForm.className = this.itemClassList[index].name
|
|
|
+ this.$forceUpdate()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
getCpClass(e){
|
|
|
this.currentCpClassId = e
|
|
|
this.app.refresh({classStyle:this.classStyle,classId:this.currentCpClassId})
|
|
|
@@ -196,7 +316,7 @@ export default {
|
|
|
})
|
|
|
.set('layout', [
|
|
|
['slot-tabs'],
|
|
|
- ['slot-cp-classStyle','slot-cp-class','search-key', 'flex1','refresh-btn'],
|
|
|
+ ['slot-cp-classStyle','slot-cp-class','search-key', 'flex1','slot-add-cp-btn','refresh-btn'],
|
|
|
['data-table'],
|
|
|
['flex1', 'pagination'],
|
|
|
])
|