|
|
@@ -49,18 +49,34 @@
|
|
|
</el-select>
|
|
|
</template>
|
|
|
|
|
|
+ <template #table-column-delStatus="{scope}">
|
|
|
+ <div v-if="scope.row.delStatus==0">
|
|
|
+ </div>
|
|
|
+ <div v-else style="color:red;font-weight:bold;">已删除</div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #table-column-name="{scope}">
|
|
|
+ <div v-if="scope.row.delStatus==0">{{scope.row.name}}</div>
|
|
|
+ <div v-else style="color:#CCCCCC;">{{scope.row.name}}</div>
|
|
|
+ </template>
|
|
|
+
|
|
|
<template #slot-column-option="{scope}">
|
|
|
- <template>
|
|
|
- <el-popover placement="top" width="160" :ref="'popover-' + scope.row.id">
|
|
|
- <p>确定要删除?</p>
|
|
|
- <div style="text-align: right; margin: 0">
|
|
|
- <el-button size="mini" type="text" @click="cancelDel(scope.row.id)">取消</el-button>
|
|
|
- <el-button type="primary" size="mini" @click="confirmDel(scope.row)">确定</el-button>
|
|
|
- </div>
|
|
|
- <el-button type="text" size="small" slot="reference">删除</el-button>
|
|
|
- </el-popover>
|
|
|
- </template>
|
|
|
+ <template>
|
|
|
+ <el-popover placement="top" width="160" :ref="'popover-' + scope.row.id">
|
|
|
+ <p>确定要删除?</p>
|
|
|
+ <div style="text-align: right; margin: 0">
|
|
|
+ <el-button size="mini" type="text" @click="cancelDel(scope.row.id)">取消</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="confirmDel(scope.row)">确定</el-button>
|
|
|
+ </div>
|
|
|
+ <el-button type="text" size="small" slot="reference">删除</el-button>
|
|
|
+ </el-popover>
|
|
|
+ </template>
|
|
|
</template>
|
|
|
+
|
|
|
+ <template #slot-modify="{scope}">
|
|
|
+ <el-button type="text" @click="replaceCpFn(scope.row.id)" style="margin-right:20px;">修改</el-button>
|
|
|
+ </template>
|
|
|
+
|
|
|
</x-crud>
|
|
|
|
|
|
<el-dialog :title="`${currentCpId == 0 ? '添加' : '修改'}产品`" :visible.sync="replaceCpPop" :close-on-click-modal="false" width="500px" >
|
|
|
@@ -75,9 +91,10 @@
|
|
|
</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-option v-for="(item, index) in cpClassData" :key="index" :value="item.id" >{{ item.name }}</el-option >
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-input v-model="replaceForm.classId" type="hidden"></el-input>
|
|
|
<el-form-item label="排序" prop="inTurn">
|
|
|
<el-input v-model="replaceForm.inTurn" placeholder="请输入数值" size="small" ></el-input>
|
|
|
</el-form-item>
|
|
|
@@ -145,8 +162,30 @@ export default {
|
|
|
},
|
|
|
computed: {},
|
|
|
methods: {
|
|
|
+ replaceConfirmFn(){
|
|
|
+ this.$refs.replaceForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let form = JSON.parse(JSON.stringify(this.replaceForm))
|
|
|
+ let host = null
|
|
|
+ if (this.currentCpId == 0) {
|
|
|
+ this.$service.ptCp.addCp(form).then(res=>{
|
|
|
+ this.$message.success('操作成功!')
|
|
|
+ this.resetForm()
|
|
|
+ this.app.refresh({ classStyle:this.classStyle,classId:this.currentCpClassId })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$service.ptCp.updateCp({ id: this.currentCpId, ...form, }).then(res=>{
|
|
|
+ this.$message.success('操作成功!')
|
|
|
+ this.resetForm()
|
|
|
+ this.app.refresh({ classStyle:this.classStyle,classId:this.currentCpClassId })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
replaceSetClass(e) {
|
|
|
- console.log(e)
|
|
|
+ this.replaceForm.classId = e
|
|
|
+ this.$forceUpdate()
|
|
|
},
|
|
|
uploadCpImg() {
|
|
|
this.$refs['replaceForm'].validateField('cover');
|
|
|
@@ -159,7 +198,6 @@ export default {
|
|
|
this.replaceCpPop = true
|
|
|
this.currentCpId = id
|
|
|
if(id == 0){
|
|
|
- this.replaceRule = {};
|
|
|
this.replaceForm = {
|
|
|
name: '',
|
|
|
classId:'',
|
|
|
@@ -168,44 +206,12 @@ export default {
|
|
|
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:'排序不能为空',
|
|
|
- }
|
|
|
- };
|
|
|
+ this.$service.ptCp.getDetail({id:id}).then(async res => {
|
|
|
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()
|
|
|
})
|
|
|
@@ -223,7 +229,7 @@ export default {
|
|
|
this.$refs[`popover-` + id].doClose();
|
|
|
},
|
|
|
confirmDel(item) {
|
|
|
- this.$service.itemCatRelate.delRelate({ itemId: item.id }).then(res => {
|
|
|
+ this.$service.ptCp.delCp({ id: item.id }).then(res => {
|
|
|
this.$message.success('删除成功');
|
|
|
this.$refs[`popover-` + item.id].doClose();
|
|
|
this.app.refresh({ classStyle:this.classStyle,classId:this.currentCpClassId })
|
|
|
@@ -285,22 +291,28 @@ export default {
|
|
|
align: 'center',
|
|
|
minWidth: 100,
|
|
|
},
|
|
|
+ {
|
|
|
+ prop: 'delStatus',
|
|
|
+ label: '状态',
|
|
|
+ align: 'center',
|
|
|
+ minWidth: 100,
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'addTime',
|
|
|
label: '创建时间',
|
|
|
align: 'center',
|
|
|
- minWidth: 180,
|
|
|
+ minWidth: 150,
|
|
|
},
|
|
|
],
|
|
|
op: {
|
|
|
visible: true,
|
|
|
props: {
|
|
|
- width: 250,
|
|
|
+ width: 200,
|
|
|
align: 'center',
|
|
|
fixed: 'right',
|
|
|
label: '操作',
|
|
|
},
|
|
|
- layout: ['slot-column-option'],
|
|
|
+ layout: ['slot-modify','slot-column-option'],
|
|
|
},
|
|
|
})
|
|
|
.set('pagination', {
|
|
|
@@ -330,7 +342,6 @@ export default {
|
|
|
showSort(e) {
|
|
|
this.sort.status = true;
|
|
|
},
|
|
|
-
|
|
|
hideSort(e) {
|
|
|
this.sort.status = false;
|
|
|
},
|