|
@@ -44,14 +44,24 @@
|
|
|
</div>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
<el-button @click="cancel">取消</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm"
|
|
|
+ :loading="loading"
|
|
|
+ >
|
|
|
+ <span v-if="loading">提交中...</span>
|
|
|
+ <span v-else>提交</span>
|
|
|
+ </el-button>
|
|
|
</span>
|
|
|
- <addStock ref="addStock" @getList="commonConfigAllFun" />
|
|
|
+ <addStock ref="addStock" @getList="updateCommonConfigAllFun" />
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import { commonConfigAllApi,commonConfigSingleApi } from "@/api/schedulingMr/schedulingMr";
|
|
|
+ import { saveCommonConfigApi,saveCommonConfigSingleApi } from "@/api/schedulingMr/schedulingMr";
|
|
|
import addStock from "./addStock.vue";
|
|
|
+
|
|
|
export default {
|
|
|
name: "stockAll",
|
|
|
components: { addStock },
|
|
@@ -95,7 +105,28 @@
|
|
|
|
|
|
|
|
|
if(res.code == 200){
|
|
|
- this.tableData = res.data.stock
|
|
|
+ let listCopy = []
|
|
|
+ res.data.stock.forEach((item,index)=>{
|
|
|
+ if(this.tableId) {
|
|
|
+ listCopy.push({
|
|
|
+ id: item.id,
|
|
|
+ seatTypeName: item.seatTypeName,
|
|
|
+ "performTimeId": item.performTimeId,
|
|
|
+ "seatTypeId": item.seatTypeId,
|
|
|
+ "stock": item.stock,
|
|
|
+ "chennelStock": this.setData(item.chennelStock)
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ listCopy.push({
|
|
|
+ seatTypeName: item.seatTypeName,
|
|
|
+ "seatTypeId": item.seatTypeId,
|
|
|
+ "stock": item.stock,
|
|
|
+ "chennelStock": this.setData(item.chennelStock)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ this.tableData = listCopy
|
|
|
let stockAllNum = 0
|
|
|
this.tableData.forEach((item,index)=>{
|
|
|
if(item.stock){
|
|
@@ -106,10 +137,47 @@
|
|
|
}
|
|
|
this.loading = false;
|
|
|
} catch (error) {
|
|
|
+ console.error(error)
|
|
|
this.loading = false;
|
|
|
this.open = false
|
|
|
}
|
|
|
},
|
|
|
+ /** 初始化值 */
|
|
|
+ setData(list) {
|
|
|
+ let listCopy = []
|
|
|
+ list.forEach((item,index)=>{
|
|
|
+ if(this.tableId){
|
|
|
+ listCopy.push({
|
|
|
+ id: item.id,
|
|
|
+ "stockId": item.stockId,
|
|
|
+ "source": item.source,
|
|
|
+ "stock": item.stock,
|
|
|
+ "soldNum": item.soldNum,
|
|
|
+ "status": item.status
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ listCopy.push({
|
|
|
+ "source": item.source,
|
|
|
+ "stock": item.stock,
|
|
|
+ "soldNum": item.soldNum,
|
|
|
+ "status": item.status
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ return listCopy
|
|
|
+ },
|
|
|
+ /** 更新列表 */
|
|
|
+ updateCommonConfigAllFun(data) {
|
|
|
+ this.tableData = data
|
|
|
+ let stockAllNum = 0
|
|
|
+ this.tableData.forEach((item,index)=>{
|
|
|
+ if(item.stock){
|
|
|
+ stockAllNum = stockAllNum + item.stock
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.stockAllNum = stockAllNum
|
|
|
+ },
|
|
|
/**
|
|
|
* 关闭弹框
|
|
|
* @date 2023-11-22
|
|
@@ -121,8 +189,34 @@
|
|
|
},
|
|
|
/** 场次库存设置 */
|
|
|
addStockFun(row) {
|
|
|
- this.$refs["addStock"].openDialog('',row,this.tableId);
|
|
|
- }
|
|
|
+ this.$refs["addStock"].openDialog('',row,this.tableId,this.tableData);
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ * @date 2023-11-22
|
|
|
+ * @returns {any}
|
|
|
+ */
|
|
|
+ async submitForm() {
|
|
|
+ try {
|
|
|
+ this.loading = true;
|
|
|
+ let res = null
|
|
|
+ if(this.tableId) {
|
|
|
+ res = await saveCommonConfigSingleApi({
|
|
|
+ "performTimeId": this.tableId,
|
|
|
+ stock: this.tableData
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ res = await saveCommonConfigApi({ stock: this.tableData });
|
|
|
+ }
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.$message.success("操作成功!");
|
|
|
+ this.loading = false;
|
|
|
+ this.cancel();
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|