addAndEdit.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912
  1. <!--
  2. * @Description: 新增/编辑弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: gcz
  6. * @LastEditTime: 2024-04-22 16:20:30
  7. * @FilePath: \great_webui\src\views\ticket\ticketMr\dialog\addAndEdit.vue
  8. * @Copyright: Copyright (c) 2016~2023 by Sugar., All Rights Reserved.
  9. -->
  10. <template>
  11. <el-dialog
  12. :title="title"
  13. :visible.sync="open"
  14. width="95%"
  15. append-to-body
  16. :close-on-click-modal="false"
  17. @close="cancel"
  18. >
  19. <div class="dialog-box">
  20. <div class="dialog">
  21. <el-form :model="form" ref="form" size="mini" :rules="rules" label-width="120px">
  22. <div style="display: flex;">
  23. <el-form-item label="模板名称:" prop="name">
  24. <el-input
  25. style="width: 350px;"
  26. v-model="form.name"
  27. placeholder="模板名称"
  28. clearable
  29. />
  30. </el-form-item>
  31. <el-form-item label="演出厅:" prop="auditoriumId">
  32. <el-select v-model="form.auditoriumId" @change="countBySeatTypFun" placeholder="请选择演出厅">
  33. <el-option
  34. v-for="item in performList"
  35. :key="item.id"
  36. :label="item.name"
  37. :value="item.id">
  38. </el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="可配置数量:">
  42. {{ seatNum }}
  43. </el-form-item>
  44. <el-form-item label="已配置数据:">
  45. {{ configStockNum }}
  46. </el-form-item>
  47. <el-form-item label="未配置数量:">
  48. {{ seatNum - configStockNum }}
  49. </el-form-item>
  50. </div>
  51. <el-form-item label="库存模式:" class="is-required">
  52. <div class="inventory_box">
  53. <div class="inventory_channel" style="width: 200px;">
  54. <div class="inventory_channel_header">
  55. <span>序号</span>
  56. <span>渠道名称</span>
  57. <span>数量</span>
  58. </div>
  59. <div
  60. :class="['inventory_channel_item',index == chennelAtion ?'inventory_channel_item-action':'']"
  61. v-for="(item,index) in form.chennelListForm"
  62. :key="index"
  63. @click="setDictLabel(item,index)"
  64. >
  65. <span>{{ index+1 }}</span>
  66. <span>{{ item.channelName }}</span>
  67. <span>{{ item.stockNum }}</span>
  68. </div>
  69. </div>
  70. <div class="inventory_seat" v-if="chennelAtion !== null">
  71. <el-form-item label="选择模式:" label-width="85px" class="is-required">
  72. <el-radio-group
  73. v-model="form.chennelListForm[chennelAtion].stockType"
  74. @change="setStockType"
  75. >
  76. <el-radio :label="0">根据数量</el-radio>
  77. <el-radio :label="1">根据座位</el-radio>
  78. </el-radio-group>
  79. </el-form-item>
  80. <div v-if="!form.chennelListForm[chennelAtion].stockType">
  81. <el-table ref="tables" v-loading="loading" :data="form.chennelListForm[chennelAtion].seatTypeList" border>
  82. <el-table-column label="序号" align="center" type="index" width="60"></el-table-column>
  83. <el-table-column label="座位类型" align="center" prop="seatTypeName" />
  84. <el-table-column label="可配置数量" align="center" prop="stock">
  85. <template slot-scope="scope">
  86. <span> {{ configStockNumObj['seatNum_'+scope.row.seatTypeId].stockTotal - configStockNumObj['seatNum_'+scope.row.seatTypeId].stockYes }} </span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="配置数量" align="center">
  90. <template slot-scope="scope">
  91. <!-- :max="configStockNumObj['seatNum_'+scope.row.seatTypeId].stockTotal - configStockNumObj['seatNum_'+scope.row.seatTypeId].stockYes" -->
  92. <el-input-number
  93. style="width: 200px;"
  94. v-model="form.chennelListForm[chennelAtion].seatTypeList[scope.$index].stockNum"
  95. clearable
  96. :min="0"
  97. placeholder="请输入数量"
  98. @change="(value)=>countNum(value,scope)"
  99. :max="configStockNumObj['seatNum_'+scope.row.seatTypeId].stockTotal - configStockNumObj['seatNum_'+scope.row.seatTypeId].stockYes"
  100. ></el-input-number>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. </div>
  105. <div v-else>
  106. <seatBox
  107. ref="seatBox"
  108. :isOccupyStatus="false"
  109. :seatTypeLimit="configStockNumObj"
  110. @selectSeat="selectSeat"
  111. />
  112. </div>
  113. </div>
  114. </div>
  115. </el-form-item>
  116. <el-form-item label="备注:" prop="remark">
  117. <el-input
  118. v-model="form.remark"
  119. type="textarea"
  120. placeholder="请输入备注"
  121. clearable
  122. />
  123. </el-form-item>
  124. </el-form>
  125. </div>
  126. <div
  127. v-if="loading"
  128. class="dialog-loading"
  129. v-loading="loading"
  130. :element-loading-text="loadingText"
  131. element-loading-spinner="el-icon-loading"
  132. element-loading-background="rgba(0, 0, 0, 0.8)"
  133. ></div>
  134. </div>
  135. <span slot="footer" class="dialog-footer">
  136. <el-button @click="cancel">关闭</el-button>
  137. <el-button
  138. v-if="model !== 'DETAILS'"
  139. type="primary"
  140. @click="submitForm"
  141. :loading="loading"
  142. >
  143. <span v-if="loading">提交中...</span>
  144. <span v-else>保存</span>
  145. </el-button>
  146. </span>
  147. <!-- 添加或修改对话框 End -->
  148. <!-- -->
  149. </el-dialog>
  150. </template>
  151. <script>
  152. import { saveAndEdit, getSelectById,countBySeatTyp,channelType } from '@/api/ticketMr/InventoryTemplate'
  153. import { getSelectById as getSeatSelectByIdApi } from "@/api/performanceHallMr/performanceHallMr";
  154. import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
  155. import { pageList as getSeatType } from '@/api/seatTypeMr/seatTypeMr'
  156. import seatBox from '@/components/seatBox/index.vue';
  157. export default {
  158. name: "addAndEdit",
  159. dicts: ['system_taxrate'],
  160. components: {
  161. seatBox
  162. },
  163. data() {
  164. return {
  165. open: false,
  166. title: "编辑",
  167. model: "EDIT",
  168. loading: false,
  169. loadingText: '获取数据中...',
  170. activeName: '01',
  171. // 演员信息弹窗
  172. performerVisible: false,
  173. // 演员信息
  174. performerList: [],
  175. // 演员上传图片索引
  176. performerIndex: 0,
  177. form: {
  178. id: undefined,
  179. chennelListForm: []
  180. },
  181. formStock: {
  182. stockType: null,
  183. chennelList: [],
  184. },
  185. rules: {
  186. name: [{ required: true, message: "请输入模板名称", trigger: ["change","blur"] }],
  187. auditoriumId: [{ required: true, message: "请选择演出厅", trigger: ["change","blur"] }],
  188. chennelList: [{ required: true, message: "请输入库存模式", trigger: ["change","blur"] }],
  189. remark: [{ required: false, message: "请输入备注", trigger: ["change","blur"] }],
  190. },
  191. statusList: [
  192. {id: 1, name: '是', value: 1},
  193. {id: 2, name: '否', value: 2},
  194. ],
  195. performList: [], // 演出厅
  196. channelTypeList: [], // 渠道
  197. dictValue: '',
  198. chennelAtion: null,
  199. countBySeatTypList: [], // 座位类型
  200. stockFormList: [],// 库存
  201. dataList: [], // 座位
  202. seatNum: '',
  203. configStockNum: 0, // 已分配的座位
  204. // 总的座位类型已分配数量
  205. configStockNumObj: {},
  206. seatTypeListAll: [], // 总的获取座位类型
  207. };
  208. },
  209. created() {
  210. this.getList()// 演出厅
  211. this.channelTypeFun() // 渠道
  212. this.getSeatTypeAllList()
  213. },
  214. methods: {
  215. /** 获取座位类型 说明 */
  216. async getSeatTypeAllList() {
  217. try {
  218. let res = await getSeatType({
  219. pageNum: 1,
  220. pageSize: 999,
  221. })
  222. if(res.code == 200) {
  223. this.seatTypeListAll = res.data.rows || [];
  224. }
  225. } catch (error) {
  226. }
  227. },
  228. /** 演出厅列表 */
  229. getList() {
  230. merchantPageList({pageNum: 1, pageSize: 100})
  231. .then(response => {
  232. this.performList = response.data.rows;
  233. }
  234. );
  235. },
  236. /**
  237. * 打开弹框
  238. * @date 2023-11-22
  239. * @param {any} obj
  240. * @returns {any}
  241. */
  242. async openDialog(title, obj, mode) {
  243. try {
  244. this.dataList = []
  245. this.model = mode
  246. this.loading = true
  247. this.loadingText = '获取数据中...'
  248. this.title = title
  249. this.chennelAtion = null
  250. this.open = true
  251. this.activeName = '01';
  252. this.configStockNumObj = {}
  253. if(this.channelTypeList.length<0) {
  254. await this.channelTypeFun()
  255. }
  256. if (obj){
  257. await this.getSelectByIdApi(obj)
  258. }else{
  259. this.form = {
  260. chennelListForm: this.setDataTree({})
  261. }
  262. console.log("list1====",this.form)
  263. this.setDictLabel(this.form.chennelListForm[0],0)
  264. }
  265. this.$nextTick(() => {
  266. this.$refs["form"].clearValidate();
  267. });
  268. } catch (error) {
  269. console.error("dfsdfdsf",error)
  270. }
  271. this.loading = false
  272. },
  273. /** 获取详情 */
  274. async getSelectByIdApi(row) {
  275. try {
  276. const id = row.id
  277. let res = await getSelectById({id})
  278. if(res.code == 200) {
  279. let obj = res.data;
  280. await this.countBySeatTypFun(obj.auditoriumId,true)
  281. obj.chennelListForm = this.setDataTree(obj)
  282. this.form = obj
  283. this.configStockNum = obj.configStockNum
  284. this.setDictLabel(obj.chennelListForm[0],0)
  285. console.log("list2====",this.form)
  286. }
  287. } catch (error) {
  288. console.log("error====",error)
  289. console.error("error====",error)
  290. }
  291. },
  292. setDataTree(obj){
  293. let list = []
  294. this.channelTypeList.forEach((item,index)=>{
  295. list.push({
  296. "channelType":item.dictValue,
  297. "channelName":item.dictLabel,
  298. "stockType": this.getStockType(item,obj),
  299. "stockNum": this.getStockAllNum(item,obj),
  300. "seatTypeList": [],
  301. "chennelSeatList": []
  302. })
  303. list[index].seatTypeList = this.getSeatTypeList(list[index],obj)
  304. list[index].chennelSeatList = this.getChennelSeatList(list[index],obj)
  305. })
  306. return list
  307. },
  308. /** 获取模式 */
  309. getStockType(obj,data){
  310. let stockType = 0
  311. if(data.chennelList && data.chennelList.length>0) {
  312. for(let i = 0;i < data.chennelList.length;i++) {
  313. if(obj.dictValue == data.chennelList[i].channelType) {
  314. stockType = data.chennelList[i].stockType
  315. break;
  316. }
  317. }
  318. }
  319. return stockType
  320. },
  321. /** 获取总数 */
  322. getStockAllNum(obj,data) {
  323. let num = 0
  324. let flog = false
  325. if(data.chennelList && data.chennelList.length>0) {
  326. data.chennelList.forEach((item,index)=>{
  327. if(obj.dictValue == item.channelType) {
  328. flog = true
  329. num = num + item.stockNum
  330. }
  331. })
  332. }
  333. if(flog) {
  334. return num
  335. }else {
  336. return ''
  337. }
  338. },
  339. /** 获取座位类型对应的数量 */
  340. getSeatTypeList(obj,data){
  341. let list1 = []
  342. this.countBySeatTypList.forEach((item1,index1)=>{
  343. list1.push({
  344. "seatTypeId": item1.seatTypeId,
  345. "seatTypeName": item1.seatTypeName,
  346. "stockNum": undefined,
  347. "stock": item1.stock,
  348. })
  349. if(obj.stockType == 0 && data.chennelList && data.chennelList.length>0) {
  350. data.chennelList.forEach((item2,index2)=>{
  351. if(item1.seatTypeId == item2.seatTypeId && obj.stockType == item2.stockType && obj.channelType == item2.channelType ) {
  352. list1[index1].stockNum = item2.stockNum
  353. }
  354. })
  355. }
  356. })
  357. return list1
  358. },
  359. /** 获取座位 */
  360. getChennelSeatList(obj,data) {
  361. let list = []
  362. let seat = {}
  363. if(data.chennelList && data.chennelList.length>0) {
  364. for(let i = 0;i<data.chennelList.length;i++) {
  365. if(obj.channelType == data.chennelList[i].channelType) {
  366. if(data.chennelList[i].chennelSeatList) {
  367. let srt = 'seat_'+ data.chennelList[i].seatTypeId
  368. if(seat[srt]) {
  369. seat[srt] = seat[srt].concat(data.chennelList[i].chennelSeatList)
  370. }else {
  371. seat[srt] = [...data.chennelList[i].chennelSeatList]
  372. }
  373. console.log("seat_",srt,seat,data.chennelList[i].chennelSeatList)
  374. }
  375. //list = data.chennelList[i].chennelSeatList ? JSON.parse(JSON.stringify(data.chennelList[i].chennelSeatList)):[]
  376. // break;
  377. }
  378. }
  379. }
  380. return JSON.stringify(seat) == '{}' ? null : seat
  381. },
  382. // setChennelList() {
  383. // },
  384. /** 价格输入事件 */
  385. changePriceAmount(key) {
  386. if(this.form[key] * 1 < 0){
  387. this.$message.error("输入需大于或等于0!");
  388. this.$set(this.form, key, '');
  389. return false
  390. }
  391. },
  392. /**
  393. * 保存
  394. * @date 2023-11-22
  395. * @returns {any}
  396. */
  397. submitForm() {
  398. this.$refs["form"].validate(async (valid,object) => {
  399. if (valid) {
  400. try {
  401. this.loading = true
  402. this.loadingText = '提交中...'
  403. console.log("this.form=====",this.form)
  404. let postMap = JSON.parse(JSON.stringify(this.form))
  405. postMap.chennelList = []
  406. for(let i = 0; i< this.form.chennelListForm.length ;i++) {
  407. let obj = {
  408. "id": null,
  409. "channelType": this.form.chennelListForm[i].channelType,
  410. "channelName": this.form.chennelListForm[i].channelName,
  411. "stockType": this.form.chennelListForm[i].stockType,
  412. }
  413. if(this.form.chennelListForm[i].stockType == 0) {
  414. if(this.form.chennelListForm[i].seatTypeList && this.form.chennelListForm[i].seatTypeList.length>0) {
  415. for(let j = 0;j< this.form.chennelListForm[i].seatTypeList.length;j++) {
  416. if(this.form.chennelListForm[i].seatTypeList[j].stockNum) {
  417. postMap.chennelList.push({
  418. ...obj,
  419. "seatTypeId": this.form.chennelListForm[i].seatTypeList[j].seatTypeId,
  420. "stockNum": this.form.chennelListForm[i].seatTypeList[j].stockNum,
  421. "chennelSeatList":null
  422. })
  423. }
  424. }
  425. }
  426. }else if(this.form.chennelListForm[i].stockType == 1 ){
  427. if(this.form.chennelListForm[i].chennelSeatList) {
  428. Object.keys(this.form.chennelListForm[i].chennelSeatList).forEach((item)=>{
  429. postMap.chennelList.push({
  430. "id": null,
  431. "channelType": this.form.chennelListForm[i].channelType,
  432. "channelName": this.form.chennelListForm[i].channelName,
  433. "stockType": this.form.chennelListForm[i].stockType,
  434. "seatTypeId": item.replace("seat_", ""),
  435. "stockNum": this.form.chennelListForm[i].chennelSeatList[item].length,
  436. "chennelSeatList": this.form.chennelListForm[i].chennelSeatList[item]
  437. })
  438. })
  439. }
  440. }
  441. }
  442. delete postMap.chennelListForm
  443. console.log("postMap=====",postMap)
  444. if(!postMap.chennelList || postMap.chennelList.length==0) {
  445. this.loading = false
  446. return
  447. }
  448. let res = await saveAndEdit(postMap)
  449. this.loading = false
  450. if(res.code) {
  451. this.$message.success(res.msg || res.message|| "操作成功");
  452. this.$emit('getList')
  453. this.cancel()
  454. }else {
  455. this.$message.error(error.msg || error.message|| "操作失败!");
  456. }
  457. } catch (error) {
  458. this.loading = false
  459. this.$message.error(error.msg || error.message|| "操作失败!");
  460. } finally {
  461. this.loading = false;
  462. }
  463. }else{
  464. // console.log('error submit!!',valid,object);
  465. if(object&&JSON.stringify(object) != '{}'){
  466. let str = ''
  467. for(let key in object){
  468. if(object.hasOwnProperty(key)){
  469. str = str + `[${object[key][0].message}]}]`
  470. }
  471. }
  472. this.$message.error(str);
  473. }
  474. }
  475. });
  476. },
  477. /**
  478. * 重置
  479. * @date 2023-11-22
  480. * @returns {any}
  481. */
  482. reset() {
  483. },
  484. /**
  485. * 关闭弹框
  486. * @date 2023-11-22
  487. * @returns {any}
  488. */
  489. cancel() {
  490. this.open = false;
  491. this.chennelAtion = null
  492. },
  493. /** 获取座位类型 */
  494. async countBySeatTypFun(value,type) {
  495. console.log("vlaue===",value)
  496. try {
  497. this.seatNum = ''
  498. this.chennelAtion = null
  499. if(!value) return
  500. let res = await countBySeatTyp({auditoriumId: value})
  501. let num = 0
  502. res.data.forEach((item,index)=>{
  503. num = num + item.stock
  504. })
  505. this.seatNum = num
  506. this.countBySeatTypList = res.data ? res.data : []
  507. let obj = {}
  508. this.countBySeatTypList.forEach((item,index)=>{
  509. obj['seatNum_'+item.seatTypeId] = {
  510. stockTotal: item.stock,
  511. stockSelect: item.stock,
  512. stockYes: 0,
  513. stockNo: 0,
  514. }
  515. })
  516. this.configStockNumObj = obj
  517. if(!type) {
  518. this.form.chennelListForm = this.setDataTree({})
  519. this.setDictLabel(this.form.chennelListForm[0],0)
  520. }
  521. } catch (error) {
  522. console.error("error1====",error)
  523. }
  524. },
  525. /** 获取渠道数据 */
  526. async channelTypeFun() {
  527. try {
  528. let res = await channelType({pageNum: 1, pageSize: 100})
  529. this.channelTypeList = res.data
  530. } catch (error) {
  531. console.error("dfsdfdsfsd====",error)
  532. }
  533. },
  534. // 选择渠道
  535. setDictLabel(obj,index){
  536. this.chennelAtion = index
  537. if(obj.stockType == 1) {
  538. this.getSeatSelectById()
  539. }else {
  540. this.countStockNum()
  541. }
  542. },
  543. // 计算可分配数量
  544. countStockNum() {
  545. let stockNum = 0
  546. let stockTotal= 0
  547. let flog = false
  548. let obj = {}
  549. this.countBySeatTypList.forEach((item,index)=>{
  550. obj['seatNum_'+item.seatTypeId] = {
  551. stockTotal: item.stock,
  552. stockSelect: item.stock,
  553. stockYes: 0,
  554. stockNo: 0,
  555. }
  556. })
  557. this.form.chennelListForm.forEach((item,index)=>{
  558. stockNum = 0
  559. if(!item.stockType && item.seatTypeList && item.seatTypeList.length>0) {
  560. item.seatTypeList.forEach((item1,index1)=>{
  561. if(item1.stockNum) {
  562. stockNum = stockNum + item1.stockNum
  563. stockTotal = stockTotal + item1.stockNum
  564. // if(!flog) {
  565. // obj['seatNum_'+item1.seatTypeId].stockYes = item1.stockNum
  566. // flog = true
  567. // }else {
  568. // obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes + item1.stockNum
  569. // }
  570. obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes + item1.stockNum
  571. }
  572. if(item1.stockNum && this.chennelAtion == index){
  573. // if(!flog) {
  574. // obj['seatNum_'+item1.seatTypeId].stockYes = 0 - item1.stockNum
  575. // flog = true
  576. // }else {
  577. // obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes - item1.stockNum
  578. // }
  579. obj['seatNum_'+item1.seatTypeId].stockYes = obj['seatNum_'+item1.seatTypeId].stockYes - item1.stockNum
  580. }
  581. })
  582. }else if(item.stockType == 1 && item.chennelSeatList){
  583. Object.keys(item.chennelSeatList).forEach((item1,index1)=>{
  584. if(item.chennelSeatList[item1]) {
  585. stockNum = stockNum + item.chennelSeatList[item1].length
  586. stockTotal = stockTotal + item.chennelSeatList[item1].length
  587. console.log("item1====",item1,item1.replace('seat_',''))
  588. // if(!flog) {
  589. // obj[item1.replace('seat_','seatNum_')].stockYes = item.chennelSeatList[item1].length
  590. // flog = true
  591. // }else {
  592. // obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes + item.chennelSeatList[item1].length
  593. // }
  594. obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes + item.chennelSeatList[item1].length
  595. }
  596. if(this.chennelAtion == index && item.chennelSeatList[item1]){
  597. // if(!flog) {
  598. // obj[item1.replace('seat_','seatNum_')].stockYes = 0 - item.chennelSeatList[item1].length
  599. // flog = true
  600. // }else {
  601. // obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes - item.chennelSeatList[item1].length
  602. // }
  603. obj[item1.replace('seat_','seatNum_')].stockYes = obj[item1.replace('seat_','seatNum_')].stockYes - item.chennelSeatList[item1].length
  604. }
  605. })
  606. }
  607. this.form.chennelListForm[index].stockNum = stockNum
  608. })
  609. console.log("this.configStockNumObj====",this.configStockNumObj)
  610. console.log("this.form====",this.form)
  611. this.configStockNumObj = obj
  612. this.configStockNum = stockTotal
  613. },
  614. // 选择模式
  615. setStockType(value) {
  616. console.log('选择模式===',value)
  617. this.form.chennelListForm[this.chennelAtion].stockNum = 0
  618. if(value == 1) {
  619. this.form.chennelListForm[this.chennelAtion].seatTypeList.forEach((item,index)=>{
  620. this.form.chennelListForm[this.chennelAtion].seatTypeList[index].stockNum = undefined
  621. })
  622. this.getSeatSelectById()
  623. }else {
  624. this.form.chennelListForm[this.chennelAtion].chennelSeatList = null
  625. }
  626. },
  627. /** 获取座位 */
  628. async getSeatSelectById() {
  629. if(!this.form.auditoriumId){ this.dataList = []; return }
  630. if(!this.dataList || this.dataList.length == 0 || this.dataList[0].auditoriumId !== this.form.auditoriumId) {
  631. let res = await getSeatSelectByIdApi(this.form.auditoriumId)
  632. this.dataList = res.data;
  633. }
  634. let list = []
  635. let list1 = []
  636. let list2 = []
  637. this.form.chennelListForm.forEach((item,index)=>{
  638. if(item.chennelSeatList && item.stockType == 1) {
  639. Object.keys(item.chennelSeatList).forEach((item1)=>{
  640. item.chennelSeatList[item1] ? list2 = list2.concat(item.chennelSeatList[item1]) : ''
  641. })
  642. }
  643. })
  644. if(this.form.chennelListForm[this.chennelAtion].chennelSeatList) {
  645. Object.keys(this.form.chennelListForm[this.chennelAtion].chennelSeatList).forEach((item)=>{
  646. list1 = list1.concat(this.form.chennelListForm[this.chennelAtion].chennelSeatList[item])
  647. })
  648. console.log("list2111=====",list2,list1)
  649. list = this.dataList.filter((item,index)=>{
  650. if(list1.includes(item.id)){
  651. this.dataList[index].occupyStatus = null // 解除被占用了
  652. return item
  653. }else if(!list1.includes(item.id) && list2.includes(item.id)){
  654. this.dataList[index].occupyStatus = 1 // 被占用了
  655. }
  656. if(!item.seatTypeId&&item.status != 2) {
  657. this.dataList[index].occupyStatus = 1 // 被占用了
  658. }
  659. })
  660. }else {
  661. this.dataList.forEach((item,index)=>{
  662. if(!list1.includes(item.id) && list2.includes(item.id)){
  663. this.dataList[index].occupyStatus = 1 // 被占用了
  664. }
  665. if(!item.seatTypeId&&item.status != 2) {
  666. this.dataList[index].occupyStatus = 1 // 被占用了
  667. }
  668. })
  669. }
  670. console.log("dfsdfdsfdsf====",list,this.form.chennelListForm[this.chennelAtion].chennelSeatList)
  671. let list3 = []
  672. this.countBySeatTypList.forEach((item,index)=>{
  673. list3.push(item.seatTypeId)
  674. })
  675. let list4 = []
  676. this.seatTypeListAll.forEach((item,index)=>{
  677. if(list3.includes(item.id)) {
  678. list4.push({...item})
  679. }
  680. })
  681. this.$nextTick(() =>{
  682. this.$refs.seatBox.querySeatListFun(true,this.dataList,list,list4)
  683. })
  684. },
  685. /** 选择座位 */
  686. selectSeat(list) {
  687. let obj = {}
  688. list.forEach((item)=>{
  689. let srt = 'seat_'+ item.seatTypeId
  690. Array.isArray(obj[srt]) ? obj[srt].push(item.id): obj[srt] = [item.id]
  691. })
  692. this.form.chennelListForm[this.chennelAtion].chennelSeatList = JSON.stringify(obj) == '{}'?null:obj
  693. this.form.chennelListForm[this.chennelAtion].stockNum = list.length>0 ? list.length : ''
  694. console.log("已选择的====",list,this.form.chennelListForm[this.chennelAtion].chennelSeatList)
  695. },
  696. /** 计算可分配座位 */
  697. countNum(value,scope) {
  698. console.log("value,index=====",value,scope)
  699. let stockNum = 0
  700. let stockTotal= 0
  701. this.form.chennelListForm.forEach((item,index)=>{
  702. stockNum = 0
  703. if(item.seatTypeList && item.seatTypeList.length>0) {
  704. item.seatTypeList.forEach((item1,index1)=>{
  705. if(item1.stockNum) {
  706. stockNum = stockNum + item1.stockNum
  707. stockTotal = stockTotal + item1.stockNum
  708. }
  709. })
  710. }
  711. this.form.chennelListForm[index].stockNum = stockNum
  712. })
  713. this.configStockNum = stockTotal
  714. }
  715. },
  716. };
  717. </script>
  718. <style lang="scss" scoped>
  719. .dialog-box {
  720. width: 100%;
  721. position: relative;
  722. .dialog-loading {
  723. width: 100%;
  724. height: 100%;
  725. position: absolute;
  726. top: 0;
  727. left: 0;
  728. }
  729. }
  730. .dialog {
  731. max-height: 70vh;
  732. overflow-y: auto;
  733. .upload-btn {
  734. width: 100px;
  735. height: 100px;
  736. background-color: #fbfdff;
  737. border: dashed 1px #c0ccda;
  738. border-radius: 5px;
  739. i {
  740. font-size: 30px;
  741. margin-top: 20px;
  742. }
  743. &-text {
  744. margin-top: -10px;
  745. }
  746. }
  747. .avatar {
  748. cursor: pointer;
  749. }
  750. }
  751. .el-table{
  752. .upload-btn {
  753. width: 100px;
  754. height: 100px;
  755. background-color: #fbfdff;
  756. border: dashed 1px #c0ccda;
  757. border-radius: 5px;
  758. i {
  759. font-size: 30px;
  760. margin-top: 20px;
  761. }
  762. &-text {
  763. margin-top: -10px;
  764. }
  765. }
  766. .avatar {
  767. cursor: pointer;
  768. }
  769. }
  770. .area-container {
  771. min-height: 400px;
  772. }
  773. ::v-deep .area-wrap-city.el-cascader {
  774. line-height: normal;
  775. .el-input {
  776. cursor: pointer;
  777. width: 100% !important;
  778. height: 28px !important;
  779. .el-input__inner {
  780. display: none !important;
  781. }
  782. span.el-input__suffix {
  783. position: inherit !important;
  784. i.el-input__icon {
  785. line-height: inherit;
  786. margin-left: 5px;
  787. }
  788. }
  789. .el-input__wrapper {
  790. box-shadow: none;
  791. input {
  792. display: none;
  793. }
  794. }
  795. }
  796. .el-cascader__tags {
  797. display: none;
  798. }
  799. }
  800. .area-city-popper {
  801. .el-cascader-panel {
  802. .el-scrollbar.el-cascader-menu {
  803. .el-cascader-menu__wrap.el-scrollbar__wrap {
  804. height: 315px;
  805. }
  806. }
  807. }
  808. }
  809. .inventory_box{
  810. width: 100%;
  811. border: 1px solid #ccc;
  812. min-height: 400px;
  813. padding: 10px;
  814. box-sizing: border-box;
  815. display: flex;
  816. flex-shrink: 0;
  817. .inventory_channel {
  818. width: 200px;
  819. >div {
  820. width: 100%;
  821. box-sizing: border-box;
  822. >span {
  823. display: flex;
  824. justify-content: center;
  825. align-items: center;
  826. border-right: 1px solid #333;
  827. }
  828. >span:nth-child(1) {
  829. width: 40px;
  830. }
  831. >span:nth-child(2) {
  832. flex: auto;
  833. }
  834. >span:nth-child(3) {
  835. width: 50px;
  836. }
  837. }
  838. .inventory_channel_header {
  839. width: 100%;
  840. height: 40px;
  841. display: flex;
  842. background-color: #ccc;
  843. border-bottom: 1px solid #333;
  844. border-top: 1px solid #333;
  845. border-left: 1px solid #333;
  846. }
  847. .inventory_channel_item {
  848. width: 100%;
  849. display: flex;
  850. height: 40px;
  851. cursor: pointer;
  852. border-bottom: 1px solid #333;
  853. border-left: 1px solid #333;
  854. }
  855. .inventory_channel_item:hover {
  856. background-color: rgba(135, 206, 235,0.6);
  857. }
  858. .inventory_channel_item-action {
  859. background-color: rgba(135, 206, 235,0.6);
  860. }
  861. }
  862. .inventory_seat {
  863. flex: auto;
  864. padding-left: 20px;
  865. box-sizing: border-box;
  866. }
  867. }
  868. </style>
  869. <style>
  870. .custom-class-box {
  871. z-index: 999999 !important;
  872. }
  873. </style>