PerFormEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <!--
  2. * @Description: 新增/编辑弹框
  3. * @Author: Sugar.
  4. * @Date: 2023-11-24 13:55:00
  5. * @LastEditors: Sugar.
  6. * @LastEditTime: 2023-11-24 13:55:00
  7. * @FilePath: \cattle_webui\src\views\venue\schedulingMr\dialog\AddOrEditDialog.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="70%"
  15. class="text-dia-log-class"
  16. append-to-body
  17. :close-on-click-modal="false"
  18. @close="cancel"
  19. >
  20. <div class="dialog">
  21. <el-form :model="form" ref="form" :rules="rules" label-width="120px">
  22. <el-form-item label="场次名称" prop="timeSnapshot">
  23. <el-input
  24. v-model="form.timeSnapshot"
  25. placeholder="场次名称"
  26. clearable
  27. style="width: 100%;"
  28. />
  29. </el-form-item>
  30. <el-form-item label="场次名称" prop="performTime">
  31. <el-time-picker
  32. v-model="form.performTimeStart"
  33. format="HH:mm"
  34. value-format="HH:mm"
  35. placeholder="开始时间">
  36. </el-time-picker>
  37. <span>—</span>
  38. <el-time-picker
  39. v-model="form.performTimeEnd"
  40. format="HH:mm"
  41. value-format="HH:mm"
  42. placeholder="结束时间">
  43. </el-time-picker>
  44. </el-form-item>
  45. <el-form-item label="选择演出厅:" prop="auditoriumId">
  46. <el-select
  47. v-model="form.auditoriumId"
  48. placeholder="选择演出厅"
  49. clearable
  50. style="width: 100%"
  51. @change="(value) =>getInventoryTemplate(value)"
  52. >
  53. <el-option
  54. v-for="dict in merchantList"
  55. :key="dict.id"
  56. :label="dict.name"
  57. :value="dict.id"
  58. />
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="选择剧目:" prop="performId">
  62. <el-select
  63. v-model="form.performId"
  64. placeholder="选择剧目"
  65. clearable
  66. @change="changePerform"
  67. style="width: 100%"
  68. >
  69. <el-option
  70. v-for="dict in goodsList"
  71. :key="dict.id"
  72. :label="dict.name"
  73. :value="dict.id"
  74. />
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="票务绑定:" prop="goodsIds">
  78. <el-select
  79. v-model="form.goodsIds"
  80. placeholder="票务绑定"
  81. clearable
  82. multiple
  83. style="width: 100%"
  84. >
  85. <el-option
  86. v-for="dict in goodsPageListS"
  87. :key="dict.id"
  88. :value="dict.id"
  89. :label="dict.status == 1 ? dict.goodsName + '(被禁用)': dict.goodsName"
  90. :disabled="dict.status != 0"
  91. >
  92. </el-option>
  93. </el-select>
  94. </el-form-item>
  95. <el-form-item label="票务绑定:" prop="stockTmpId">
  96. <el-select
  97. v-model="form.stockTmpId"
  98. placeholder="选择库存模板"
  99. clearable
  100. style="width: 100%"
  101. >
  102. <el-option
  103. v-for="dict in inventoryTemplateList"
  104. :key="dict.id"
  105. :label="dict.name"
  106. :value="dict.id"
  107. :disabled="dict.status != 1"
  108. />
  109. </el-select>
  110. </el-form-item>
  111. </el-form>
  112. </div>
  113. <span slot="footer" class="dialog-footer">
  114. <el-button @click="cancel">取消</el-button>
  115. <el-button
  116. type="primary"
  117. @click="submitForm"
  118. v-loading.fullscreen.lock="loading"
  119. element-loading-text="提交中..."
  120. element-loading-spinner="el-icon-loading"
  121. element-loading-background="rgba(0, 0, 0, 0.8)"
  122. >
  123. <span v-if="loading">提交中...</span>
  124. <span v-else>保存</span>
  125. </el-button>
  126. </span>
  127. </el-dialog>
  128. </template>
  129. <script>
  130. import { insertOrUpdateApi, goodsPageListNew, getPerformTimeById } from "@/api/ticketMr/schedulingConfiguration";
  131. import { goodsPageList } from '@/api/programmeMr/programmeMr'
  132. import { merchantPageList } from '@/api/performanceHallMr/performanceHallMr'
  133. import { pageList as getInventoryTemplateApi } from '@/api/ticketMr/InventoryTemplate'
  134. import { getToken } from "@/utils/auth";
  135. import moment from "moment"
  136. export default {
  137. name: "addAndEdit",
  138. data() {
  139. return {
  140. title: "编辑",
  141. model: "EDIT",
  142. open: false,
  143. loading: false,
  144. tableType: false,
  145. form: {
  146. id: undefined,
  147. planSessionList: [],
  148. insertType: '1',
  149. useStock: 0,
  150. weekDay: [],
  151. weekType: 0
  152. },
  153. rules: {
  154. auditoriumId: [{ required: true, message: "请选择演出厅", trigger: ["change","blur"] }],
  155. performId: [{ required: true, message: "请选择剧目", trigger: ["change","blur"] }],
  156. performDate: [{ required: true, message: "请选择日期", trigger: ["change","blur"] }],
  157. planSessionList: [{ required: true, message: "请添加场次", trigger: ["change","blur"] }],
  158. goodsIds: [{ required: true, message: "请选择票务", trigger: ["change","blur"] }],
  159. weekType: [{ required: true, message: "请选择星期", trigger: ["change","blur"] }],
  160. },
  161. uploadObj: {
  162. url: process.env.VUE_APP_UPLOAD_FILE_API + "/upload/single/minio",
  163. Headers: { Authorization: "Bearer " + getToken() },
  164. },
  165. theatreList: [],
  166. goodsList: [],
  167. merchantList: [],
  168. editType: false,
  169. selectPerform: {},
  170. goodsPageListS: [], // 票务
  171. inventoryTemplateList: []
  172. };
  173. },
  174. created() {
  175. /** 获取票务 */
  176. this.goodsPageList(); // 剧目列表
  177. this.merchantPageList('') // 演出厅
  178. //this.getInventoryTemplate()
  179. },
  180. methods: {
  181. /**
  182. * 打开弹框
  183. * @date 2023-11-22
  184. * @param {any} obj
  185. * @returns {any}
  186. */
  187. async openDialog(title, obj, type) {
  188. this.open = true;
  189. this.editType = false;
  190. if (obj && type == "EDIT"){
  191. this.title = "编辑排期";
  192. this.form = {
  193. "id": obj.id,
  194. "performId": obj.performId,
  195. "auditoriumId": obj.auditoriumId,
  196. "performDate": obj.performDate,
  197. "performTimeStart": obj.performTimeStart,
  198. "performTimeEnd": obj.performTimeEnd,
  199. "timeSnapshot": obj.timeSnapshot,
  200. "useStock": obj.useStock,
  201. "stockTmpId": obj.stockTmpId,
  202. goodsIds: obj.goodsIds ? obj.goodsIds.split(','):[],
  203. }
  204. if(obj.performId) {
  205. await this.goodsPageListFun(obj.performId);
  206. }
  207. await this.getInventoryTemplate(obj.auditoriumId)
  208. }else{
  209. this.title = "新增排期";
  210. this.form = {};
  211. }
  212. this.$nextTick(() => {
  213. this.$refs["form"].clearValidate();
  214. });
  215. },
  216. /** 剧目选择 */
  217. changePerform(id) {
  218. this.goodsList.forEach(item => {
  219. if(id == item.id){
  220. this.selectPerform = item;
  221. }
  222. })
  223. this.goodsPageListS = []
  224. if(id) {
  225. this.goodsPageListFun(id);
  226. }
  227. this.$set(this.form, 'goodsIds' , [])
  228. },
  229. /** 剧目列表查询 */
  230. goodsPageList() {
  231. goodsPageList(this.addDateRange({pageNum: 1, pageSize: 100, status: 1}))
  232. .then(response => {
  233. this.goodsList = response.data.rows;
  234. });
  235. },
  236. /** 演出厅列表查询 */
  237. merchantPageList(id) {
  238. merchantPageList(this.addDateRange({theatreId: id, pageNum: 1, pageSize: 100}))
  239. .then(response => {
  240. this.merchantList = response.data.rows;
  241. });
  242. },
  243. /** 票务信息 */
  244. async goodsPageListFun(value){
  245. try {
  246. if(!this.form.auditoriumId || !this.form.performId) {
  247. this.goodsPageListS = []
  248. return
  249. }
  250. let res = await goodsPageListNew({
  251. performId: this.form.performId,
  252. auditoriumId: this.form.auditoriumId
  253. })
  254. if(res.code == 200){
  255. this.goodsPageListS = res.data
  256. }
  257. } catch (error) {
  258. }
  259. },
  260. /** 获取模板 */
  261. async getInventoryTemplate(value,type){
  262. try {
  263. if(this.form.planSessionList && this.form.planSessionList.length > 0 && type) {
  264. let list = JSON.parse(JSON.stringify(this.form.planSessionList))
  265. list.forEach((item,index)=>{
  266. list[index].stockTmpId = null
  267. })
  268. this.$set(this.form,'planSessionList',list)
  269. }
  270. if(!value) {
  271. this.inventoryTemplateList = []
  272. return
  273. }
  274. await this.goodsPageListFun(value)
  275. // 获取库存模板
  276. let res = await getInventoryTemplateApi({
  277. auditoriumId: value,
  278. pageNum: 1,
  279. pageSize: 1000,
  280. })
  281. if(res.code == 200){
  282. this.inventoryTemplateList = res.data.rows
  283. }
  284. } catch (error) {
  285. console.error("error===",error)
  286. }
  287. },
  288. /**
  289. * 保存
  290. * @date 2023-11-22
  291. * @returns {any}
  292. */
  293. submitForm() {
  294. this.$refs["form"].validate(async (valid) => {
  295. if (valid) {
  296. try {
  297. let postEdit = JSON.parse(JSON.stringify(this.form))
  298. postEdit.goodsIds = postEdit.goodsIds.join(',')
  299. delete postEdit.performDate
  300. this.loading = true;
  301. const { code } = await insertOrUpdateApi({ ...postEdit });
  302. if (code === 200) {
  303. this.$message.success("操作成功!");
  304. this.$emit("getList");
  305. this.cancel();
  306. }
  307. } catch (error) {
  308. console.error("error====",error)
  309. } finally {
  310. this.loading = false;
  311. }
  312. }
  313. });
  314. },
  315. /**
  316. * 重置
  317. * @date 2023-11-22
  318. * @returns {any}
  319. */
  320. reset() {
  321. },
  322. /**
  323. * 关闭弹框
  324. * @date 2023-11-22
  325. * @returns {any}
  326. */
  327. cancel() {
  328. this.reset();
  329. this.open = false;
  330. },
  331. },
  332. };
  333. </script>
  334. <style lang="scss" scoped>
  335. .dialog {
  336. height: 65vh;
  337. overflow-y: auto;
  338. }
  339. .dialog {
  340. .upload-btn {
  341. width: 100px;
  342. height: 100px;
  343. background-color: #fbfdff;
  344. border: dashed 1px #c0ccda;
  345. border-radius: 5px;
  346. i {
  347. font-size: 30px;
  348. margin-top: 20px;
  349. }
  350. &-text {
  351. margin-top: -10px;
  352. }
  353. }
  354. .avatar {
  355. cursor: pointer;
  356. }
  357. }
  358. </style>