ticket.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <div class="form-wrap">
  3. <el-form
  4. class="searchBox"
  5. ref="form"
  6. :model="form"
  7. :inline="true"
  8. label-width="140px"
  9. >
  10. <div class="block-title">
  11. 查询条件
  12. </div>
  13. <el-form-item
  14. label="名称"
  15. prop="ticketTypeName"
  16. >
  17. <el-input v-model="form.ticketTypeName"></el-input>
  18. </el-form-item>
  19. <el-form-item
  20. label="类型"
  21. prop="category"
  22. >
  23. <el-select v-model="form.category">
  24. <el-option
  25. value=""
  26. label="全部"
  27. ></el-option>
  28. <el-option
  29. v-for="item in ticketCategory"
  30. :key="item.id"
  31. :value="item.id"
  32. :label="item.name">
  33. </el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item
  37. label="是否可售"
  38. prop="isSale"
  39. >
  40. <el-select v-model="form.isSale">
  41. <el-option
  42. label="全部"
  43. value=""
  44. ></el-option>
  45. <el-option
  46. label="是"
  47. :value="1"
  48. ></el-option>
  49. <el-option
  50. label="否"
  51. :value="0"
  52. ></el-option>
  53. </el-select>
  54. </el-form-item>
  55. <div class="btn-wrap">
  56. <el-button
  57. @click="reset"
  58. >
  59. 重置
  60. </el-button>
  61. <el-button
  62. type="primary"
  63. @click="getTicketTypeList"
  64. >
  65. 搜索
  66. </el-button>
  67. <el-button
  68. type="primary"
  69. @click="showDialog('add')"
  70. >
  71. 新增票种
  72. </el-button>
  73. </div>
  74. </el-form>
  75. <div class="tableBox">
  76. <div class="block-title">
  77. 现有票种
  78. </div>
  79. <el-table
  80. border
  81. stripe
  82. v-loading="loading"
  83. :data="tableData"
  84. >
  85. <el-table-column
  86. prop="name"
  87. label="票种名称"
  88. >
  89. </el-table-column>
  90. <!-- <el-table-column
  91. prop="id"
  92. label="票种ID"
  93. width="80"
  94. >
  95. </el-table-column> -->
  96. <el-table-column
  97. label="票种分类"
  98. >
  99. <template slot-scope="scope">
  100. {{ getTicketCate(scope.row.category) }}
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="price"
  105. label="窗口价格"
  106. >
  107. </el-table-column>
  108. <el-table-column
  109. label="在售状态"
  110. >
  111. <template slot-scope="scope">
  112. <el-tag :type="scope.row.isSale | runStopColor">
  113. {{ scope.row.isSale ? '在售' : '禁售' }}
  114. </el-tag>
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. label="操作"
  119. >
  120. <template slot-scope="scope">
  121. <el-link
  122. type="primary"
  123. size="small"
  124. @click="showDialog('edit', scope.row)"
  125. >
  126. 编辑
  127. </el-link>
  128. <el-link
  129. type="primary"
  130. size="small"
  131. @click="showDialog('priceCalendar', scope.row)"
  132. >
  133. 价格日历
  134. </el-link>
  135. <br>
  136. <el-link
  137. type="primary"
  138. size="small"
  139. @click="showDialog('add', itemWithoutCategoryAndShorthand(scope.row))"
  140. >
  141. 复制
  142. </el-link>
  143. <el-link
  144. type="primary"
  145. size="small"
  146. @click="deleteTicket(scope.row.id)"
  147. >
  148. 删除
  149. </el-link>
  150. </template>
  151. </el-table-column>
  152. </el-table>
  153. <el-pagination
  154. background
  155. :current-page.sync="form.pageNum"
  156. :page-size="10"
  157. layout="total, prev, pager, next"
  158. @current-change="getTicketTypeList"
  159. :total="total">
  160. </el-pagination>
  161. </div>
  162. <!-- 票种弹框 -->
  163. <ElDialog
  164. :title="dialogType === 'add' ? '新增票种' : '编辑票种'"
  165. width="1100px"
  166. v-model="dialogVisible">
  167. <!-- 新增与编辑 共用一个弹出 -->
  168. <TicketDialog
  169. :dialog-type="dialogType"
  170. :ticket-item="curItem"
  171. :scenic-list="scenicList"
  172. :ticket-tag-list="ticketTagList"
  173. :member-type-list="memberTypeList"
  174. :invoice-seller="InvoiceSeller"
  175. @updateList="getTicketTypeList"
  176. ></TicketDialog>
  177. </ElDialog>
  178. <PriceCalendar ref="priceCalendar"></PriceCalendar>
  179. </div>
  180. </template>
  181. <script>
  182. import moment from 'moment'
  183. import { getTicketTypeList, deleteTicket, getScenic, updateTicket, listInvoiceSales } from '@/api/ticketType'
  184. import { getTicketTypeTagList } from '@/api/ticketTypeTag'
  185. import { getMemberType } from '@/api/member'
  186. import ElDialog from '@/components/Dialog'
  187. import TicketDialog from './ticket/Dialog'
  188. import PriceCalendar from './ticket/PriceCalendar'
  189. import { TicketCategory } from './ticket/constant'
  190. import { cloneDeep } from '@/utils'
  191. export default {
  192. computed: {
  193. ticketCategory () {
  194. return this.$store.state.app.ticketCategory
  195. }
  196. },
  197. data () {
  198. return {
  199. form: {
  200. ticketTypeName: '',
  201. category: '',
  202. keyWords3: '',
  203. isSale: '',
  204. pageNum: 1,
  205. pageSize: 10,
  206. keyWords6: '',
  207. keyWords7: '',
  208. keyWords8: '',
  209. ticketTypeName0: '1',
  210. // ticketTypeName1: 1, // 只查看自己绑定景点的票种
  211. ticketTypeName2: ''
  212. },
  213. loading: false,
  214. total: 0,
  215. tableData: [],
  216. memberTypeList: [],
  217. dialogVisible: false,
  218. // 弹框类型 'add' 或 'edit'
  219. dialogType: '',
  220. curItem: {},
  221. scenicList: [],
  222. ticketTagList: [],
  223. ticketPricePlanList: [],
  224. InvoiceSeller: []
  225. }
  226. },
  227. created () {
  228. this.getScenicList()
  229. this.getTicketTypeList()
  230. // this.getMemberList()
  231. // this.getTicketTagList()
  232. // this.getTicketPricePlanList()
  233. // this.getInvoiceSeller()
  234. },
  235. components: {
  236. ElDialog,
  237. TicketDialog,
  238. PriceCalendar
  239. },
  240. methods: {
  241. getTicketCate (cate) {
  242. return TicketCategory[cate]
  243. },
  244. getInvoiceSeller () {
  245. listInvoiceSales({}).then(res => {
  246. this.InvoiceSeller = res?.data
  247. })
  248. },
  249. getTicketTagList () {
  250. getTicketTypeTagList({}).then(res => {
  251. this.ticketTagList = res.children
  252. })
  253. },
  254. // 获取景点列表
  255. getScenicList () {
  256. getScenic().then(res => {
  257. this.scenicList = res?.data.records || []
  258. })
  259. },
  260. showDialog (type, item) {
  261. if (type === 'priceCalendar') {
  262. this.$refs.priceCalendar.show(item)
  263. return
  264. }
  265. this.dialogType = type
  266. this.curItem = item
  267. this.dialogVisible = true
  268. },
  269. // '创建票种失败,名称或助记符重复' 复制时去掉名称和助记符,待复制时用户填入
  270. itemWithoutCategoryAndShorthand (item) {
  271. const copyItem = cloneDeep(item)
  272. copyItem.name = '' // 名称
  273. return copyItem
  274. },
  275. getMemberList () {
  276. getMemberType({
  277. pageNum: 0,
  278. pageSize: 0
  279. }).then(res => {
  280. this.memberTypeList = res.list
  281. })
  282. },
  283. // 获取票种列表
  284. getTicketTypeList () {
  285. this.loading = true
  286. getTicketTypeList(this.form).then(res => {
  287. this.tableData = res.data.records.map(item => {
  288. item.scenics = item.ticketTypeScenicList.map(s => s.scenicName).join('、')
  289. return item
  290. })
  291. console.log('this.tableData', this.tableData)
  292. this.total = res.data.total || 0
  293. }).finally(() => {
  294. this.loading = false
  295. })
  296. // 更新全局票种列表
  297. // this.$store.dispatch('getTicketTypeList')
  298. },
  299. // 删除票种
  300. deleteTicket (id) {
  301. this.$confirm('确定删除?', '提示', {
  302. confirmButtonText: '确定',
  303. cancelButtonText: '取消',
  304. type: 'warning'
  305. }).then(() => {
  306. deleteTicket(id).then(res => {
  307. this.$message.success('删除成功')
  308. this.getTicketTypeList()
  309. })
  310. })
  311. },
  312. reset () {
  313. this.$refs.form.resetFields()
  314. },
  315. offSale (data) {
  316. let form = Object.assign({}, data)
  317. form.isSale = 0
  318. updateTicket(form).then(res => {
  319. if (res.code !== '200') {
  320. this.$message.success(res.msg || '操作失败')
  321. return
  322. }
  323. this.$message.success('操作成功')
  324. this.getTicketTypeList()
  325. })
  326. },
  327. onSale (data) {
  328. let saleEnd = moment(data.saleDateEnd).hours(23).minutes(59).seconds(59)
  329. if (moment().isAfter(saleEnd)) {
  330. this.$alert('请修改票种可售日期', '票种已过期', {
  331. confirmButtonText: '知道了'
  332. })
  333. } else {
  334. let form = Object.assign({}, data)
  335. form.isSale = 1
  336. updateTicket(form).then(res => {
  337. if (res.code !== '200') {
  338. this.$message.success(res.msg || '操作失败')
  339. return
  340. }
  341. this.$message.success('操作成功')
  342. this.getTicketTypeList()
  343. })
  344. }
  345. }
  346. }
  347. }
  348. </script>
  349. <style lang="scss" scoped>
  350. .offSale-btn{
  351. color: #F56C6C
  352. }
  353. .onSale-btn{
  354. color: #67C23A
  355. }
  356. </style>