EditDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <el-form
  3. inline
  4. :model="form"
  5. ref="form"
  6. class="form-wrap"
  7. label-width="140px">
  8. <div class="dialog-info">
  9. <div class="block-title">基础信息</div>
  10. <el-form-item
  11. verify
  12. class="is-required"
  13. prop="ticketTypeId"
  14. label="票种">
  15. <el-select
  16. v-model="form.ticketTypeId"
  17. :disabled="dialogType === 'edit'"
  18. filterable>
  19. <el-option
  20. v-for="item in ticketTypeList"
  21. :key="item.id"
  22. :label="`${item.ticketTypeId}-${item.name}-${CategoryDict[item.category] || ''}`"
  23. :value="item.ticketTypeId"></el-option>
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item
  27. verify
  28. class="is-required"
  29. prop="otaSourceIds"
  30. label="分销商">
  31. <el-select
  32. v-model="form.otaSourceIds"
  33. multiple
  34. filterable
  35. :disabled="dialogType === 'edit'">
  36. <el-option
  37. v-for="item in otaList"
  38. :key="item.id"
  39. :label="item.otaSourceName"
  40. :value="item.otaSourceId"></el-option>
  41. </el-select>
  42. </el-form-item>
  43. <el-form-item
  44. verify
  45. class="is-required"
  46. label="市场价"
  47. prop="marketPrice">
  48. <el-input-number
  49. controls-position="right"
  50. v-model="form.marketPrice"
  51. :min="0"
  52. :precision="2"></el-input-number>
  53. <el-tooltip
  54. effect="dark"
  55. content="划线价"
  56. placement="top"
  57. >
  58. <i class="el-icon-info"></i>
  59. </el-tooltip>
  60. </el-form-item>
  61. <el-form-item
  62. verify
  63. class="is-required"
  64. label="结算价"
  65. prop="settlementPrice">
  66. <el-input-number
  67. controls-position="right"
  68. v-model="form.settlementPrice"
  69. :min="0"
  70. :precision="2"></el-input-number>
  71. <el-tooltip
  72. effect="dark"
  73. content="分销商和景区结算的价格"
  74. placement="top"
  75. >
  76. <i class="el-icon-info"></i>
  77. </el-tooltip>
  78. </el-form-item>
  79. <el-form-item
  80. verify
  81. class="is-required"
  82. label="售卖价"
  83. prop="salePrice">
  84. <el-input-number
  85. controls-position="right"
  86. v-model="form.salePrice"
  87. :min="0"
  88. :precision="2"></el-input-number>
  89. <el-tooltip
  90. effect="dark"
  91. content="分销商实际售卖价"
  92. placement="top"
  93. >
  94. <i class="el-icon-info"></i>
  95. </el-tooltip>
  96. </el-form-item>
  97. <el-form-item label="在售状态">
  98. <el-switch
  99. v-model="form.isSale"
  100. :inactive-value="0"
  101. :active-value="1">
  102. </el-switch>
  103. <span>{{ form.isSale ? '在售' : '禁售' }}</span>
  104. </el-form-item>
  105. <el-form-item
  106. label="库存"
  107. prop="totalStock">
  108. <el-input-number
  109. controls-position="right"
  110. v-model="form.totalStock"
  111. :min="-1"
  112. :precision="0"></el-input-number>
  113. <el-tooltip
  114. effect="dark"
  115. :content="stockContent"
  116. placement="top"
  117. >
  118. <i class="el-icon-info"></i>
  119. </el-tooltip>
  120. </el-form-item>
  121. <el-form-item
  122. verify
  123. class="is-required"
  124. label="是否实名制购票"
  125. prop="realNameType">
  126. <el-select v-model="form.realNameType">
  127. <el-option
  128. :value="0"
  129. label="不限"></el-option>
  130. <el-option
  131. :value="1"
  132. label="一证一人"></el-option>
  133. <el-option
  134. :value="2"
  135. label="一证多人"></el-option>
  136. </el-select>
  137. </el-form-item>
  138. <el-form-item
  139. v-if="hasXc"
  140. verify
  141. class="is-required"
  142. label="携程产品参数"
  143. prop="xcRealNameType">
  144. <el-select v-model="form.xcRealNameType">
  145. <el-option
  146. :value="1"
  147. label="一张一人需要证件"></el-option>
  148. <el-option
  149. :value="2"
  150. label="一张一人不需要证件"></el-option>
  151. <el-option
  152. :value="3"
  153. label="一单一人需要证件"></el-option>
  154. <el-option
  155. :value="4"
  156. label="一单一人不需要证件"></el-option>
  157. </el-select>
  158. </el-form-item>
  159. <div class="block-title">销售时间及使用时间</div>
  160. <div
  161. class="clearfix"
  162. style="width:100%"></div>
  163. <el-form-item
  164. verify
  165. class="is-required"
  166. prop="saleDateStart"
  167. label="售卖时间">
  168. <el-date-picker
  169. v-model="form.saleDateStart"
  170. type="date"
  171. :picker-options="dateOption"
  172. placeholder="选择日期时间"
  173. default-time="00:00:00">
  174. </el-date-picker>
  175. </el-form-item>
  176. <el-form-item
  177. verify
  178. prop="saleDateEnd"
  179. label-width="80"
  180. label="至">
  181. <el-date-picker
  182. v-model="form.saleDateEnd"
  183. type="date"
  184. :picker-options="dateOption"
  185. placeholder="选择日期时间"
  186. default-time="23:59:59">
  187. </el-date-picker>
  188. </el-form-item>
  189. <el-form-item
  190. verify
  191. class="is-required"
  192. label="使用日期"
  193. prop="useDateStart">
  194. <el-date-picker
  195. v-model="form.useDateStart"
  196. type="date"
  197. placeholder="开始时间">
  198. </el-date-picker>
  199. </el-form-item>
  200. <el-form-item
  201. verify
  202. label="至"
  203. label-width="80"
  204. prop="useDateEnd">
  205. <el-date-picker
  206. v-model="form.useDateEnd"
  207. type="date"
  208. placeholder="结束时间">
  209. </el-date-picker>
  210. </el-form-item>
  211. </div>
  212. <div class="dialog-btn-wrap">
  213. <el-button @click="reset">重置</el-button>
  214. <el-button
  215. @click="submit"
  216. type="primary">保存</el-button>
  217. </div>
  218. </el-form>
  219. </template>
  220. <script>
  221. import { addOTATicketSale, updateOTATicketSale } from '@/api/otaTicketSale'
  222. import moment from 'moment'
  223. import { CategoryDict } from '@/const'
  224. export default {
  225. props: {
  226. dialogType: {
  227. type: String,
  228. default: ''
  229. },
  230. currentItem: {
  231. type: Object,
  232. default: () => {}
  233. },
  234. otaList: {
  235. type: Array,
  236. default: () => []
  237. },
  238. ticketTypeList: {
  239. type: Array,
  240. default: () => []
  241. },
  242. batchConfigList: {
  243. type: Array,
  244. default: () => []
  245. },
  246. performList: {
  247. type: Array,
  248. default: () => []
  249. }
  250. },
  251. computed: {
  252. mtID () {
  253. const mtID = this.otaList.find(item => item.otaSourceName === '美团网酒旅')
  254. return mtID ? mtID.id : 9999
  255. },
  256. xcID () {
  257. const xcID = this.otaList.find(item => item.otaSourceName === '携程网')
  258. return xcID ? xcID.id : 9999
  259. },
  260. hasXc () {
  261. return this.form.otaSourceIds.some(id => !!this.otaList.find(item => item.otaSourceId === id && item.otaSourceCode === 'XC'))
  262. }
  263. },
  264. data () {
  265. return {
  266. CategoryDict,
  267. visible: false,
  268. selectedBatch: {}, // 节目场次
  269. performBatchList: [], // 节目场次列表
  270. seatAreaList: [],
  271. seatAreas: [],
  272. batches: [],
  273. projectName: localStorage.getItem('otaProject'),
  274. dateOption: {
  275. disabledDate (theTime) {
  276. let startTime = moment().format('YYYY-MM-DD') + ' 00:00:00'
  277. return moment(theTime).isBefore(startTime)
  278. }
  279. },
  280. form: {
  281. id: '',
  282. otaSourceIds: [],
  283. ticketTypeId: '',
  284. isSale: 1,
  285. salePrice: 0,
  286. marketPrice: 0,
  287. settlementPrice: 0,
  288. realNameType: 0,
  289. saleDateStart: moment().format('YYYY-MM-DD'),
  290. saleDateEnd: moment().add(20, 'years').endOf('year').format('YYYY-MM-DD'),
  291. useDateStart: moment().format('YYYY-MM-DD'),
  292. useDateEnd: moment().add(30, 'years').endOf('year').format('YYYY-MM-DD'),
  293. totalStock: -1, // -1代表不限库存
  294. xcRealNameType: ''
  295. },
  296. showDeletedOption: false,
  297. deletedOption: {
  298. name: '',
  299. id: 0
  300. },
  301. stockContent: `1.-1代表无限库存
  302. 2.已消耗库存数为用户历次下单门票张数之和,不包含退票
  303. 3.修改库存数后,用户历史下单门票张数仍计算在内`
  304. }
  305. },
  306. watch: {
  307. visible (val) {
  308. this.reset()
  309. if (val) {
  310. this.showDeletedOption = false
  311. if (this.dialogType === 'edit' && this.currentItem) {
  312. this.form = Object.assign({}, this.form, this.currentItem)
  313. console.log('this.form', this.form)
  314. this.form.otaSourceIds = this.form.otaSourceId ? [this.form.otaSourceId] : []
  315. // 有绑定场次的情况
  316. const batch = this.batchConfigList.find(v => v.id === this.form.batchConfigId)
  317. if (!batch && this.form.batchConfigId !== 0 && this.dialogType === 'edit') { // 有绑定场次 且该场次在不在现有可选范围中 ==》原来绑定的场次被删了 要保证正常显示 手动加这一项
  318. this.showDeletedOption = true
  319. this.deletedOption.name = this.form.batchConfigName
  320. this.deletedOption.id = this.form.batchConfigId
  321. } else {
  322. this.showDeletedOption = false
  323. }
  324. } else {
  325. this.form.batchConfigId = 0
  326. this.form.batchConfigIds = []
  327. }
  328. }
  329. }
  330. },
  331. methods: {
  332. handleClose () {
  333. this.$parent.handleClose()
  334. },
  335. reset () {
  336. this.$refs.form.resetFields()
  337. },
  338. submit () {
  339. this.$refs.form.validate((valid) => {
  340. if (valid) {
  341. switch (this.dialogType) {
  342. case 'add':
  343. this.addTicket()
  344. break
  345. case 'edit':
  346. this.updateTicket()
  347. break
  348. }
  349. } else {
  350. console.log('error submit!!')
  351. return false
  352. }
  353. })
  354. },
  355. addTicket () {
  356. const params = Object.assign({}, this.form)
  357. delete params.id
  358. addOTATicketSale(params).then(res => {
  359. this.$message.success('添加成功')
  360. this.reset()
  361. this.handleClose()
  362. this.$emit('updateList')
  363. })
  364. },
  365. updateTicket () {
  366. const params = Object.assign({}, this.form)
  367. updateOTATicketSale(params).then(res => {
  368. this.$message.success('保存成功')
  369. this.reset()
  370. this.handleClose()
  371. this.$emit('updateList')
  372. })
  373. }
  374. }
  375. }
  376. </script>
  377. <style lang="scss">
  378. .manual-label {
  379. margin: 0;
  380. padding-right: 12px;
  381. box-sizing: border-box;
  382. text-align: right;
  383. display: inline-block;
  384. width: 140px;
  385. }
  386. .xs-input {
  387. width: 90px !important;
  388. .el-input, .el-input--small {
  389. width: 90px;
  390. }
  391. }
  392. </style>