|
@@ -18,9 +18,27 @@
|
|
|
@close="cancel"
|
|
|
>
|
|
|
<div class="dialog" v-loading="loading">
|
|
|
+ <el-button type="primary" v-if="tableData.length == 0 " @click="addTable()">添加</el-button>
|
|
|
<div v-for="(item,index) in tableData" :key="index" :style="{display: 'flex',marginBottom: '10px',alignItems:tableId ? 'flex-start' : 'center'}">
|
|
|
<div :style="{display: 'flex',minWidth: '150px',justifyContent: 'flex-end',padding: tableId ? '8px 0 0 0' : '0px'}">
|
|
|
- <dict-tag :options="dict.type.order_form_type" :value="item.source"/>:
|
|
|
+ <dict-tag v-if="useStock == 1" :options="dict.type.order_form_type" :value="item.source"/>
|
|
|
+ <el-select
|
|
|
+ v-model="tableData[index].source"
|
|
|
+ placeholder="请选择渠道"
|
|
|
+ clearable
|
|
|
+ style="width: 100%"
|
|
|
+ v-if="useStock == 0"
|
|
|
+ @click="(value)=>selectSource(value,index)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="dict in dict.type.order_form_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :disabled="sourceList.includes(Number(dict.value))"
|
|
|
+ :value="Number(dict.value)"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ :
|
|
|
</div>
|
|
|
<div v-if="!tableId" style="display: flex;margin-left: 20px;align-items: center;">
|
|
|
<span style="margin-right: 10px;">库存</span>
|
|
@@ -28,15 +46,20 @@
|
|
|
</div>
|
|
|
<div v-if="tableId" style="margin-left: 20px;">
|
|
|
<el-radio-group v-model="tableData[index].status" @change="(value)=>changeRadio(value,index)">
|
|
|
- <div>
|
|
|
+ <div style="display: flex;align-items: center;">
|
|
|
<el-radio :label="0">在售</el-radio>
|
|
|
<el-input-number placeholder="请输入库存" :disabled="tableData[index].status == 1" v-model="tableData[index].stock" controls-position="right"></el-input-number>
|
|
|
+ <div style="display: flex;width: 100px;color: #333;font-size: 16px;align-items: center;justify-content: center;">已售:{{ item.soldNum }}</div>
|
|
|
</div>
|
|
|
<div style="margin-top: 10px;">
|
|
|
<el-radio :label="1">售罄</el-radio>
|
|
|
</div>
|
|
|
</el-radio-group>
|
|
|
</div>
|
|
|
+ <div v-if="tableId && useStock==0" style="margin-left: 20px;">
|
|
|
+ <el-button type="primary" v-if="index == tableData.length-1" @click="addTable(index)">添加</el-button>
|
|
|
+ <el-button type="danger" @click="clearTable(index)">移除</el-button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
@@ -67,7 +90,11 @@
|
|
|
tableData: [], // 票务
|
|
|
stock: {},
|
|
|
tableId: '',
|
|
|
- allData: {}
|
|
|
+ allData: {},
|
|
|
+ useStock: 0,
|
|
|
+ chennelStock: [],
|
|
|
+ sourceList: [],
|
|
|
+ stockAllNum: 0,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -77,14 +104,26 @@
|
|
|
* @param {any} obj
|
|
|
* @returns {any}
|
|
|
*/
|
|
|
- async openDialog(title,data,id,allData) {
|
|
|
- console.log("data,id,allData====",data,id)
|
|
|
+ async openDialog(title,data,id,allData,useStock) {
|
|
|
+ console.log("data,id,allData====",data,id,useStock)
|
|
|
this.open = true;
|
|
|
this.tableId = id
|
|
|
+ this.useStock = useStock
|
|
|
this.stock = JSON.parse(JSON.stringify(data))
|
|
|
this.tableData = JSON.parse(JSON.stringify(data.chennelStock))
|
|
|
+ this.chennelStock = JSON.parse(JSON.stringify(data.chennelStock))
|
|
|
+ this.sourceList = []
|
|
|
+ this.stockAllNum = 0
|
|
|
+ let stockAllNum = 0
|
|
|
+ this.chennelStock.forEach(item=>{
|
|
|
+ this.sourceList.push(item.source)
|
|
|
+ if(item.soldNum) {
|
|
|
+ stockAllNum += item.soldNum
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.stockAllNum = this.stock.stock - stockAllNum
|
|
|
this.allData = JSON.parse(JSON.stringify(allData))
|
|
|
- this.title = title
|
|
|
+ this.title = title + `(可分配库存:${ this.stockAllNum })`
|
|
|
},
|
|
|
/** 票务信息 */
|
|
|
async saveCommonConfigFun(value){
|
|
@@ -111,11 +150,19 @@
|
|
|
*/
|
|
|
async submitForm() {
|
|
|
let count = 0
|
|
|
+ let flog = false
|
|
|
this.tableData.forEach((item,index)=>{
|
|
|
- count = count + (item.stock?item.stock:0) + (item.soldNum?item.soldNum:0)
|
|
|
+ count = count + (item.stock?item.stock:0) // + (item.soldNum?item.soldNum:0)
|
|
|
+ if((!item.source && item.source !=0) || (!item.stock && item.stock !=0)) {
|
|
|
+ flog = true
|
|
|
+ }
|
|
|
})
|
|
|
+ if( flog ) {
|
|
|
+ this.$message.error("渠道和售库存不能为空!");
|
|
|
+ return
|
|
|
+ }
|
|
|
console.log("count====",count)
|
|
|
- if( this.stock.stock < count ) {
|
|
|
+ if( this.stockAllNum < count ) {
|
|
|
this.$message.error("渠道在售库存和已售数量总合不能大于总库存!");
|
|
|
return
|
|
|
}
|
|
@@ -164,6 +211,38 @@
|
|
|
if(value == 1){
|
|
|
this.$set(this.tableData[index],'stock',0)
|
|
|
}
|
|
|
+ },
|
|
|
+ /** 我是谁 */
|
|
|
+ addTable(){
|
|
|
+ this.tableData.push({
|
|
|
+ "stockId": null,
|
|
|
+ "source": null,
|
|
|
+ "stock": 0,
|
|
|
+ "soldNum": 0,
|
|
|
+ "status": 0
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 谁是我 */
|
|
|
+ clearTable(index){
|
|
|
+ let list = JSON.parse(JSON.stringify(this.sourceList))
|
|
|
+ list.forEach((item,i)=>{
|
|
|
+ if(this.tableData[index].source == item) {
|
|
|
+ this.sourceList.splice(i,1)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ console.log("this.sourceList===",this.sourceList)
|
|
|
+ this.tableData.splice(index,1)
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ /** */
|
|
|
+ selectSource(value,i) {
|
|
|
+ this.sourceList.push(value)
|
|
|
+ this.$set(this.tableData[i],'soldNum',0)
|
|
|
+ this.chennelStock.forEach((item,index)=>{
|
|
|
+ if(value == item.source) {
|
|
|
+ this.$set(this.tableData[i],'soldNum',item.soldNum)
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
};
|