|
@@ -21,18 +21,56 @@
|
|
|
</el-input>
|
|
|
</template>
|
|
|
<template v-slot:radio>
|
|
|
- <el-radio v-model="radio" :label="1" @input="isSingle=true">单规格</el-radio>
|
|
|
- <el-radio v-model="radio" :label="2" @input="isSingle=false">多规格</el-radio>
|
|
|
+ <el-radio v-model="materialSpec" :label="0" @input="changeSingle">单规格</el-radio>
|
|
|
+ <el-radio v-model="materialSpec" :label="1" @input="changeSingle">多规格</el-radio>
|
|
|
</template>
|
|
|
- <template v-slot:attribute>
|
|
|
- <div v-if="isSingle">
|
|
|
- <el-select v-model="selectValue" clearable placeholder="请选择" style="width: 19.5%;">
|
|
|
+ <template v-slot:attributeName>
|
|
|
+ <div v-if="isSingle" key="item4">
|
|
|
+ <by-table :propConfig="singleTable" ref="singeTable"></by-table>
|
|
|
+ </div>
|
|
|
+ <div v-if="!isSingle" key="item5">
|
|
|
+ <el-select v-model="selectValue" clearable placeholder="请选择" style="width: 19.5%;"
|
|
|
+ @input="getSelectValue">
|
|
|
<el-option v-for="item in selectList" :key="item.value" :label="item.name" :value="item.id">
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
- </div>
|
|
|
- <div v-if="!isSingle">
|
|
|
- <ForTab />
|
|
|
+ <div class="by-tab" v-if="isTab" key="item6">
|
|
|
+
|
|
|
+
|
|
|
+ <div v-for="(item,index) of columns" :key="index">
|
|
|
+ <div class="title">{{item.title}} <i class="el-icon-circle-close" @click="closeGroup(index)"></i>
|
|
|
+ </div>
|
|
|
+ <el-tag class="item-tab" :disable-transitions="true" :key="i" v-for="(tag,i) of item.list" closable
|
|
|
+ @close="handleClose(tag,index)">
|
|
|
+ {{tag}}
|
|
|
+ </el-tag>
|
|
|
+ <by-input class="input-new-tag" :ref="'getValue_'+index"></by-input>
|
|
|
+ <el-button class="button-new-tag" @click="showInput(index)">添加</el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div style="margin: 20px 0;" v-if="!isAdd" key="item7">
|
|
|
+ <div class="el-button mr15 el-button--primary el-button--small" @click="isAdd=true">添加新规格</div>
|
|
|
+ <div @click="generateNow" class="el-button el-button--success el-button--small">立即生成</div>
|
|
|
+ </div>
|
|
|
+ <div style="display: flex;margin: 20px 0;" v-else key='item8'>
|
|
|
+ <div class="flex-item">
|
|
|
+ <label>规格:</label>
|
|
|
+ <div class="el-input el-input--small" style="width: 250px;">
|
|
|
+ <input type="text" v-model="norms" placeholder="请输入规格" class="el-input__inner">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="flex-item">
|
|
|
+ <label>规格值:</label>
|
|
|
+ <div class="el-input el-input--small" style="width: 250px;">
|
|
|
+ <input type="text" v-model="normsValue" placeholder="请输入规格值" class="el-input__inner">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div @click="doComfirm" class="el-button el-button--primary el-button--small">确定</div>
|
|
|
+ <div @click="isAdd=false" class="el-button el-button--danger el-button--small">取消</div>
|
|
|
+ </div>
|
|
|
+ <div v-if="isTable" key="item9"><by-table :propConfig="tableConfig" ref="table"></by-table></div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<template v-slot:status>
|
|
@@ -48,6 +86,18 @@
|
|
|
<el-radio v-model="issued" :label="1">是</el-radio>
|
|
|
<el-radio v-model="issued" :label="2">否</el-radio>
|
|
|
</template>
|
|
|
+ <template v-slot:tags>
|
|
|
+ <!-- <div v-for="(item,index) of tabList" :key="index">
|
|
|
+ <div class="title">{{item.title}} <i class="el-icon-circle-close" @click="closeGroup(index)"></i>
|
|
|
+ </div>
|
|
|
+ <el-tag class="item-tab" :disable-transitions="true" :key="i" v-for="(tag,i) of item.list" closable
|
|
|
+ @close="handleClose(tag,index)">
|
|
|
+ {{tag}}
|
|
|
+ </el-tag>
|
|
|
+ <by-input class="input-new-tag" :ref="'getValue_'+index"></by-input>
|
|
|
+ <el-button class="button-new-tag" @click="showInput(index)">添加</el-button>
|
|
|
+ </div> -->
|
|
|
+ </template>
|
|
|
</by-form>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -64,12 +114,12 @@
|
|
|
@Component({ components: { ForTab,ImportProduct } })
|
|
|
export default class productManagement extends Vue {
|
|
|
isShow = 'home'
|
|
|
- isClick = false
|
|
|
+ isEdit = true
|
|
|
isSingle : any = true
|
|
|
timeNum = 0;
|
|
|
timer : any = null
|
|
|
data : any = []
|
|
|
- radio : any = 1
|
|
|
+ materialSpec : any = 0
|
|
|
radioStatus : any = 1
|
|
|
ismakeup : any = 1
|
|
|
issued : any = 1
|
|
@@ -77,6 +127,288 @@
|
|
|
categoryId : any = ''
|
|
|
selectList = []
|
|
|
selectValue = ''
|
|
|
+ tabList = []
|
|
|
+ // tab
|
|
|
+ columns : any = []
|
|
|
+ inputValue : any = ''
|
|
|
+ norms : any = ''
|
|
|
+ normsValue : any = ''
|
|
|
+ isAdd : any = false
|
|
|
+ isTab : any = false
|
|
|
+ isTable : any = false
|
|
|
+ skuRuleList : any = ''
|
|
|
+ tableList : any = ''
|
|
|
+ attributeId : any = ''
|
|
|
+ // tab
|
|
|
+ singleTable : any = {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ height: 78,
|
|
|
+ align: 'center',
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ // {
|
|
|
+ // title: '标题',
|
|
|
+ // field: 'skuTitle',
|
|
|
+ // component: 'by-input',
|
|
|
+ // compConfig: {
|
|
|
+ // attr: {
|
|
|
+ // size: 'mini',
|
|
|
+ // placeholder: ' '
|
|
|
+ // },
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // title: '副标题',
|
|
|
+ // field: 'skuSubtitle',
|
|
|
+ // component: 'by-input',
|
|
|
+ // compConfig: {
|
|
|
+ // attr: {
|
|
|
+ // size: 'mini',
|
|
|
+ // placeholder: ' '
|
|
|
+ // },
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '价格',
|
|
|
+ field: 'price',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '库存',
|
|
|
+ field: 'stock',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '保质期(天)',
|
|
|
+ field: 'shelfLife',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '重量',
|
|
|
+ field: 'weight',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '长',
|
|
|
+ field: 'length',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '宽',
|
|
|
+ field: 'width',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '高',
|
|
|
+ field: 'height',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ // width: '100px',
|
|
|
+ title: '体积',
|
|
|
+ field: 'volume',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ tableConfig : any = {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ height: 486,
|
|
|
+ align: 'center',
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ title: '标题',
|
|
|
+ field: 'skuTitle',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '副标题',
|
|
|
+ field: 'skuSubtitle',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '价格',
|
|
|
+ field: 'price',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '库存',
|
|
|
+ field: 'stock',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '保质期(天)',
|
|
|
+ field: 'shelfLife',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '重量',
|
|
|
+ field: 'weight',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '长',
|
|
|
+ field: 'length',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '宽',
|
|
|
+ field: 'width',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '高',
|
|
|
+ field: 'height',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '100px',
|
|
|
+ title: '体积',
|
|
|
+ field: 'volume',
|
|
|
+ component: 'by-input',
|
|
|
+ compConfig: {
|
|
|
+ attr: {
|
|
|
+ size: 'mini',
|
|
|
+ placeholder: ' '
|
|
|
+ },
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ width: '80px',
|
|
|
+ title: '操作',
|
|
|
+ action: true,
|
|
|
+ plugins: [{
|
|
|
+ icon: 'el-icon-delete',
|
|
|
+ name: '删除',
|
|
|
+ audit: '',
|
|
|
+ event: {
|
|
|
+ click: (item : any) => {
|
|
|
+ (this as any).doDeleteTable(item)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
props = {
|
|
|
label: 'name',
|
|
|
value: 'id',
|
|
@@ -95,9 +427,15 @@
|
|
|
name: [{
|
|
|
required: true, message: '请输入名称', trigger: 'blur'
|
|
|
}],
|
|
|
- shortName: [{
|
|
|
- required: true, message: '请输入简称', trigger: 'blur'
|
|
|
- }]
|
|
|
+ // categoryName: [{
|
|
|
+ // required: true, message: '请输入物料分类', trigger: 'blur'
|
|
|
+ // }],
|
|
|
+ // vmCategoryName: [{
|
|
|
+ // required: true, message: '请输入虚拟分类', trigger: 'blur'
|
|
|
+ // }],
|
|
|
+ // organizationCategoryName: [{
|
|
|
+ // required: true, message: '请输入机构商品分类', trigger: 'blur'
|
|
|
+ // }]
|
|
|
}
|
|
|
},
|
|
|
columns: [
|
|
@@ -266,14 +604,14 @@
|
|
|
{
|
|
|
span: 6,
|
|
|
label: '物料分类',
|
|
|
- prop: 'select',
|
|
|
+ prop: 'categoryName',
|
|
|
component: 'select-tree',
|
|
|
compConfig: {
|
|
|
attr: {
|
|
|
label: 'name',
|
|
|
clearable: true,
|
|
|
retConfig: {
|
|
|
- // treeName:'name',
|
|
|
+ categoryName: 'name',
|
|
|
categoryId: 'id'
|
|
|
}
|
|
|
},
|
|
@@ -285,14 +623,14 @@
|
|
|
{
|
|
|
span: 6,
|
|
|
label: '虚拟分类',
|
|
|
- prop: 'select',
|
|
|
+ prop: 'vmCategoryName',
|
|
|
component: 'select-tree',
|
|
|
compConfig: {
|
|
|
attr: {
|
|
|
label: 'name',
|
|
|
clearable: true,
|
|
|
retConfig: {
|
|
|
- // treeName:'name',
|
|
|
+ vmCategoryName: 'name',
|
|
|
vmCategoryId: 'id'
|
|
|
}
|
|
|
},
|
|
@@ -304,14 +642,14 @@
|
|
|
{
|
|
|
span: 6,
|
|
|
label: '机构商品分类',
|
|
|
- prop: 'select',
|
|
|
+ prop: 'organizationCategoryName',
|
|
|
component: 'select-tree',
|
|
|
compConfig: {
|
|
|
attr: {
|
|
|
label: 'name',
|
|
|
clearable: true,
|
|
|
retConfig: {
|
|
|
- treeName: 'name',
|
|
|
+ organizationCategoryName: 'name',
|
|
|
organizationCategoryId: 'id'
|
|
|
}
|
|
|
},
|
|
@@ -321,8 +659,6 @@
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
- [
|
|
|
- ],
|
|
|
[
|
|
|
{
|
|
|
span: 30,
|
|
@@ -344,7 +680,7 @@
|
|
|
span: 30,
|
|
|
label: '物料属性',
|
|
|
slot: true,
|
|
|
- prop: 'attribute',
|
|
|
+ prop: 'attributeName',
|
|
|
}
|
|
|
],
|
|
|
[
|
|
@@ -371,6 +707,14 @@
|
|
|
prop: 'issued',
|
|
|
}
|
|
|
],
|
|
|
+ [
|
|
|
+ {
|
|
|
+ span: 20,
|
|
|
+ label: '标签',
|
|
|
+ slot: true,
|
|
|
+ prop: 'tags',
|
|
|
+ }
|
|
|
+ ],
|
|
|
],
|
|
|
|
|
|
}
|
|
@@ -578,12 +922,268 @@
|
|
|
this.getDataList()
|
|
|
}, 500)
|
|
|
}
|
|
|
+ // 保存编辑/新增
|
|
|
+ doFormData() {
|
|
|
+ (this as any).$refs.form.validate().then(() => {
|
|
|
+ let query = (this as any).$refs.form.getValue();
|
|
|
+ // console.log('物料信息 ==> ',query);
|
|
|
+ query.materialSpec = this.materialSpec; // 商品规格
|
|
|
+ query.attributeList = JSON.stringify(this.columns) // 物料属性
|
|
|
+ query.attributeId = this.attributeId // 物料属性ID
|
|
|
+ query.status = this.radioStatus; // 物料状态
|
|
|
+ // query.ismakeup = this.ismakeup; // 商品组合
|
|
|
+ query.issued = this.issued; // 是否公布
|
|
|
+ query.description = this.textarea; // 备注
|
|
|
+ let data : any = {}
|
|
|
+ // 多规格
|
|
|
+ if (this.materialSpec === 1) {
|
|
|
+ if (this.tableList.length <= 0) return (this as any).$message({ type: 'warning', message: '请点击生成规格!' });
|
|
|
+ data = { maindataMaterial: query, maindataMaterialSkus: (this as any).$refs.table.getValue() }
|
|
|
+ let newArray : any = []
|
|
|
+ let materialSpecList : any = []
|
|
|
+ // console.log('表格数据 ==> ', this.tableList);
|
|
|
+ this.tableList.map((v : any) => {
|
|
|
+ for (let kyes in v) {
|
|
|
+ if (kyes.indexOf('_field_name') != -1) {
|
|
|
+ let key = kyes.split('_field_name')[0]
|
|
|
+ newArray.push({ [key]: v[kyes] })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // console.log(newArray);
|
|
|
+ for (var i = 0; i < newArray.length; i += 2) {
|
|
|
+ materialSpecList.push(newArray.slice(i, i + 2));
|
|
|
+ }
|
|
|
+ // console.log('materialSpecList ==> ', materialSpecList);
|
|
|
+ data.maindataMaterialSkus.map((v : any, i : any) => {
|
|
|
+ v.materialSpec = JSON.stringify(materialSpecList[i])
|
|
|
+ })
|
|
|
+ } else { // 单规格
|
|
|
+ data = { maindataMaterial: query, maindataMaterialSkus: (this.$refs.singeTable as any).getValue() }
|
|
|
+ data.maindataMaterialSkus[0].isDeleted = 0;
|
|
|
+ data.maindataMaterial.attributeList = ""
|
|
|
+ }
|
|
|
+ console.log('data ==> ', data);
|
|
|
+
|
|
|
+ if (this.isEdit) { // 编辑
|
|
|
+ other.updateSpuAndSku(data, 'maindataMaterial').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.isShow = 'home';
|
|
|
+ this.getDataList();
|
|
|
+ this.$message({ type: 'success', message: res.msg })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else { // 新增
|
|
|
+ other.saveSpuAndSku(data, 'maindataMaterial').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.isShow = 'home';
|
|
|
+ this.getDataList();
|
|
|
+ this.$message({ type: 'success', message: res.msg })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 新增
|
|
|
+ onAdd() {
|
|
|
+ this.isShow = 'add';
|
|
|
+ this.materialSpec = 0; // 单规格
|
|
|
+ this.isSingle = true; // 显示单规格表格
|
|
|
+ this.isEdit = false
|
|
|
+ setTimeout(() => {
|
|
|
+ (this as any).$refs.form.clearValue(); // 设置表单数据
|
|
|
+ (this as any).$refs.singeTable.setValue([{}]) // 设置单表格数据
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ // 编辑
|
|
|
+ getDetail(e : any) {
|
|
|
+ console.log('编辑 ==> ', e);
|
|
|
+ let loading = this.$loading({ target: '.my-container' })
|
|
|
+ api.single({ id: e.categoryId }, 'maindataMaterialCategory').then((res : any) => {
|
|
|
+ if (res.code === 200) e.categoryName = res.data.name
|
|
|
+ }).then(() => {
|
|
|
+ api.single({ id: e.vmCategoryId }, 'maindataMaterialVmcategory').then((res : any) => {
|
|
|
+ if (res.code === 200) e.vmCategoryName = res.data.name
|
|
|
+ }).then(() => {
|
|
|
+ api.single({ id: e.organizationCategoryId }, 'maindataMaterialOrganizationCategory').then((res : any) => {
|
|
|
+ if (res.code === 200) e.organizationCategoryName = res.data.name
|
|
|
+ }).then(() => {
|
|
|
+ if (e.attributeId) {
|
|
|
+ api.single({ id: e.attributeId }, 'maindataMaterialAttribute').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ if (res.data) this.selectValue = res.data.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.isEdit = true;
|
|
|
+ this.isShow = 'add';
|
|
|
+ this.materialSpec = e.materialSpec
|
|
|
+ this.isSingle = e.materialSpec === 0 ? true : false;
|
|
|
+ this.isTab = true;
|
|
|
+ if (e.attributeList) this.columns = JSON.parse(e.attributeList);
|
|
|
+ other.selectByMaterialId({ id: e.id }, 'maindataMaterialSku').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ if (this.isSingle) {
|
|
|
+ (this as any).$refs.singeTable.setValue(res.data)
|
|
|
+ } else {
|
|
|
+ this.isTable = true;
|
|
|
+ this.forFun(this.columns[0], 0) // 生成sku
|
|
|
+ let tableConfig = (this as any).$lodash.cloneDeep(this.tableConfig);
|
|
|
+ // let skuRuleList = (this as any).$lodash.cloneDeep(this.skuRuleList);
|
|
|
+ this.tableList = (this as any).$lodash.cloneDeep(this.skuRuleList);
|
|
|
+ let newColumns = (this as any).$lodash.cloneDeep(this.columns).reverse();
|
|
|
+ res.data.map((v : any, i : any) => {
|
|
|
+ v = Object.assign(v, this.tableList[i])
|
|
|
+ v.dataIndex = i
|
|
|
+ })
|
|
|
+ newColumns.map((v : any) => {
|
|
|
+ tableConfig.columns.unshift({
|
|
|
+ width: '100px',
|
|
|
+ title: v.title,
|
|
|
+ field: v.field,
|
|
|
+ })
|
|
|
+ });
|
|
|
+ this.tabList = (this as any).$lodash.cloneDeep(res.data);
|
|
|
+ console.log('表格配置 ==> ', tableConfig);
|
|
|
+ console.log('表格数据 ==> ', this.tabList);
|
|
|
+ setTimeout(() => {
|
|
|
+ (this as any).$refs.table.setTableConfig(tableConfig); // 设置表格配置
|
|
|
+ (this as any).$refs.table.setValue(this.tabList) // 设置表格数据
|
|
|
+ }, 300)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ (this as any).$refs.form.setValue(e)
|
|
|
+ loading.close()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+ showInput(index : any) {
|
|
|
+ let inputValue = (this as any).$refs['getValue_' + index][0].getValue();
|
|
|
+ console.log(this.columns[index]);
|
|
|
+ if (this.columns[index].list.indexOf(inputValue) !== -1) return (this as any).$refs['getValue_' + index][0].clearValue();
|
|
|
+ if (inputValue) {
|
|
|
+ this.columns[index].list.push(inputValue);
|
|
|
+ }
|
|
|
+ (this as any).$refs['getValue_' + index][0].clearValue();
|
|
|
+ }
|
|
|
+ // 立即生成
|
|
|
+ generateNow() {
|
|
|
+ this.isTable = true;
|
|
|
+ this.forFun(this.columns[0], 0) // 生成sku
|
|
|
+ let data = (this as any).$lodash.cloneDeep(this.tableConfig);
|
|
|
+ this.tableList = (this as any).$lodash.cloneDeep(this.skuRuleList);
|
|
|
+ let newColumns = (this as any).$lodash.cloneDeep(this.columns).reverse();
|
|
|
+ this.tableList.map((v : any, i : any) => {
|
|
|
+ v.dataIndex = i
|
|
|
+ v.isDeleted = 0
|
|
|
+ })
|
|
|
+ newColumns.map((v : any) => {
|
|
|
+ data.columns.unshift({
|
|
|
+ width: '100px',
|
|
|
+ title: v.title,
|
|
|
+ field: v.field,
|
|
|
+ })
|
|
|
+ });
|
|
|
+ console.log('表格数据 ==> ', this.tableList);
|
|
|
+ console.log('表格配置 ==> ', data);
|
|
|
+ setTimeout(() => {
|
|
|
+ (this as any).$refs.table.setValue(this.tableList); // 设置表格数据
|
|
|
+ (this as any).$refs.table.setTableConfig(data); // 设置表格配置
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ // 切换商品规格
|
|
|
+ changeSingle() {
|
|
|
+ if (this.isSingle) {
|
|
|
+ this.isSingle = false
|
|
|
+ } else {
|
|
|
+ this.isSingle = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ (this as any).$refs.singeTable.setValue([{}]) // 设置单表格数据
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 添加sku规格
|
|
|
+ doComfirm() {
|
|
|
+ if (!this.normsValue || !this.norms) return (this as any).$message({ type: "warning", message: '请添加完整的规格!' })
|
|
|
+ let obj : any = {
|
|
|
+ title: this.norms,
|
|
|
+ field: this.norms + '_field_name',
|
|
|
+ list: [this.normsValue]
|
|
|
+ }
|
|
|
+ this.columns.push(obj);
|
|
|
+ this.norms = '';
|
|
|
+ this.normsValue = '';
|
|
|
+ this.isAdd = false;
|
|
|
+ }
|
|
|
+ // 排序生成
|
|
|
+ forFun(data : any, i : number, v ?: any) {
|
|
|
+ if (data.list) {
|
|
|
+ let d : Array<any> = [];
|
|
|
+ // data.list = data.list.reverse()
|
|
|
+ data.list.forEach((item : any) => {
|
|
|
+ if (i == 0) { // 第一次循环
|
|
|
+ let obj : any = {}
|
|
|
+ obj[data.field] = item
|
|
|
+ d.push(obj);
|
|
|
+ } else {
|
|
|
+ // v = v.reverse()
|
|
|
+ v.forEach((ele : any) => {
|
|
|
+ let obj : any = {};
|
|
|
+ obj = (this as any).$lodash.clone(ele);
|
|
|
+ obj[data.field] = item
|
|
|
+ d.push(obj);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ i++
|
|
|
+ if (this.columns[i]) {
|
|
|
+ this.forFun(this.columns[i], i, d);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ this.skuRuleList = d;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 删除表格数据
|
|
|
+ doDeleteTable(item : any) {
|
|
|
+ console.log((this as any).tableList);
|
|
|
+ // this.tableList.splice(item.dataIndex, 1);
|
|
|
+ // this.tableList.map((v : any, i : any) => {
|
|
|
+ // v.dataIndex = i
|
|
|
+ // });
|
|
|
+ // (this as any).$refs.table.setValue(this.tableList); // 设置表格数据
|
|
|
+ }
|
|
|
+ // 删除标签
|
|
|
+ handleClose(tag : any, index : any) {
|
|
|
+ // console.log(tag);
|
|
|
+ this.columns[index].list.splice(this.columns[index].list.indexOf(tag), 1);
|
|
|
+ }
|
|
|
+ // 删除数组
|
|
|
+ closeGroup(index : any) {
|
|
|
+ this.columns.splice(index, 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更换物料属性数据
|
|
|
+ getSelectValue(e : any) {
|
|
|
+ api.single({ id: e }, 'maindataMaterialAttribute').then((res : any) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.columns = JSON.parse(res.data.attributeValue);
|
|
|
+ this.tableList = []
|
|
|
+ this.attributeId = e
|
|
|
+ this.isTab = true;
|
|
|
+ this.isTable = false;
|
|
|
+ // console.log(this.columns);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
// 获取物料属性
|
|
|
getAttribute() {
|
|
|
api.pageList({}, 'maindataMaterialAttribute').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
this.selectList = res.data.records
|
|
|
- console.log(this.selectList);
|
|
|
} else this.failHandle(res)
|
|
|
})
|
|
|
}
|
|
@@ -627,34 +1227,6 @@
|
|
|
} else this.failHandle(res)
|
|
|
})
|
|
|
}
|
|
|
- // 保存编辑/新增
|
|
|
- doFormData() {
|
|
|
- (this as any).$refs.form.validate().then(() => {
|
|
|
- let data = (this as any).$refs.form.getValue();
|
|
|
- if (this.isClick) { // 编辑
|
|
|
- api.updateList(data, 'maindataMaterial').then((res : any) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.isShow = 'home';
|
|
|
- this.getDataList();
|
|
|
- this.$message({ type: 'success', message: res.msg })
|
|
|
- }
|
|
|
- })
|
|
|
- } else { // 新增
|
|
|
- data.description = this.textarea;
|
|
|
- data.status = this.radioStatus;
|
|
|
- data.ismakeup = this.ismakeup;
|
|
|
- data.issued = this.issued;
|
|
|
- console.log(data);
|
|
|
- api.saveList(data, 'maindataMaterial').then((res : any) => {
|
|
|
- if (res.code === 200) {
|
|
|
- this.isShow = 'home';
|
|
|
- this.getDataList();
|
|
|
- this.$message({ type: 'success', message: res.msg })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
// 工具栏方法
|
|
|
clickHandle(e : any) {
|
|
|
if (e === 'onRefresh') (this.$refs.moduleView as any).resert();
|
|
@@ -668,19 +1240,6 @@
|
|
|
if (e === 'onReturn') this.isShow = 'home';
|
|
|
if (e === 'onSave') this.doFormData();
|
|
|
}
|
|
|
- // 新增
|
|
|
- onAdd() {
|
|
|
- if (this.isClick) (this as any).$refs.form.setValue({})
|
|
|
- this.isShow = 'add';
|
|
|
- this.isClick = false;
|
|
|
- }
|
|
|
- // 编辑
|
|
|
- getDetail(e : any) {
|
|
|
- this.isClick = true;
|
|
|
- this.isShow = 'add';
|
|
|
- // (this as any).getAttribute();
|
|
|
- (this as any).$refs.form.setValue(e)
|
|
|
- }
|
|
|
// 工具栏删除
|
|
|
doDelete() {
|
|
|
let selectData = (this.$refs.moduleView as any).getSelectData()
|
|
@@ -697,7 +1256,7 @@
|
|
|
type: 'warning',
|
|
|
center: true
|
|
|
}).then(() => {
|
|
|
- api.deleteList({ ids: ids }, 'maindataMaterial').then((res : any) => {
|
|
|
+ other.deleteSpuAndSku({ ids: ids }, 'maindataMaterial').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
this.getDataList();
|
|
|
this.$message({
|
|
@@ -721,7 +1280,7 @@
|
|
|
type: 'warning',
|
|
|
center: true
|
|
|
}).then(() => {
|
|
|
- api.deleteList({ ids: item.id }, 'maindataMaterial').then((res : any) => {
|
|
|
+ other.deleteSpuAndSku({ ids: item.id }, 'maindataMaterial').then((res : any) => {
|
|
|
if (res.code === 200) {
|
|
|
this.getDataList();
|
|
|
this.$message({
|
|
@@ -769,22 +1328,31 @@
|
|
|
}
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
- .fade-leave,
|
|
|
- .fade-enter-to {
|
|
|
- opacity: 1;
|
|
|
- }
|
|
|
-
|
|
|
- .fade-leave-to,
|
|
|
- .fade-enter {
|
|
|
- opacity: 0;
|
|
|
- }
|
|
|
-
|
|
|
.my-container {
|
|
|
width: 100%;
|
|
|
box-sizing: border-box;
|
|
|
display: flex;
|
|
|
padding: 16px;
|
|
|
|
|
|
+ .by-tab {
|
|
|
+ .title {
|
|
|
+ padding: 10px 0 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .item-tab {
|
|
|
+ margin-right: 16px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .input-new-tag {
|
|
|
+ width: 130px;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ .flex-item {
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.search-btn {
|
|
|
width: 100%;
|
|
|
display: flex;
|