index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="90px"
  9. >
  10. <el-form-item label="盲票组名称" prop="title">
  11. <el-input
  12. v-model="queryParams.title"
  13. placeholder="请输入盲票组名称"
  14. clearable
  15. size="small"
  16. style="width: 240px"
  17. @clear="handleQuery"
  18. @keyup.enter.native="handleQuery"
  19. />
  20. </el-form-item>
  21. <el-form-item label="盲票组类型" prop="type">
  22. <el-select
  23. v-model="queryParams.type"
  24. placeholder="请选择盲票组类型"
  25. clearable
  26. size="small"
  27. @change="handleQuery"
  28. >
  29. <el-option label="全部" value="" />
  30. <el-option label="线上票" value="online" />
  31. <el-option label="线下票" value="offline" />
  32. </el-select>
  33. </el-form-item>
  34. <el-form-item label="盲票组状态" prop="status">
  35. <el-select
  36. v-model="queryParams.status"
  37. placeholder="请选择盲票组状态"
  38. clearable
  39. size="small"
  40. @change="handleQuery"
  41. >
  42. <el-option label="全部" value="" />
  43. <el-option label="待出票" value="wait" />
  44. <el-option label="出票中" value="doing" />
  45. <el-option label="待上架" value="done" />
  46. <el-option label="已上架" value="on" />
  47. <el-option label="已下架" value="off" />
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button
  52. type="primary"
  53. icon="el-icon-search"
  54. size="mini"
  55. @click="handleQuery"
  56. >搜索</el-button
  57. >
  58. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  59. >重置</el-button
  60. >
  61. </el-form-item>
  62. </el-form>
  63. <el-row :gutter="10" class="mb8">
  64. <el-col :span="1.5">
  65. <el-button
  66. type="primary"
  67. icon="el-icon-plus"
  68. size="mini"
  69. @click="handleAdd"
  70. v-hasPermi="['business:ticket:add']"
  71. >添加盲票组</el-button
  72. >
  73. </el-col>
  74. <!--<el-col :span="1.5">
  75. <el-button
  76. type="info"
  77. plain
  78. icon="el-icon-upload2"
  79. size="mini"
  80. @click="handleImport"
  81. v-hasPermi="['business:ticket:import']"
  82. >导入</el-button
  83. >
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-button
  87. type="warning"
  88. plain
  89. icon="el-icon-download"
  90. size="mini"
  91. :loading="exportLoading"
  92. @click="handleExport"
  93. v-hasPermi="['business:ticket:export']"
  94. >导出</el-button
  95. >
  96. </el-col>-->
  97. <el-col :span="1.5">
  98. <el-button
  99. type="infor"
  100. plain
  101. icon="el-icon-printer"
  102. size="mini"
  103. :loading="exportLoading"
  104. @click="handleExportDraw"
  105. v-hasPermi="['business:ticket:export']"
  106. >导出印刷</el-button
  107. >
  108. </el-col>
  109. <right-toolbar
  110. :showSearch.sync="showSearch"
  111. @queryTable="getList()"
  112. ></right-toolbar>
  113. </el-row>
  114. <el-table
  115. ref="table"
  116. v-loading="loading"
  117. :data="list"
  118. @select="handleSelect"
  119. class="ticket-table" @sort-change="sortChannelId"
  120. >
  121. <el-table-column
  122. type="selection"
  123. width="55"
  124. align="center"
  125. fixed="left"
  126. />
  127. <el-table-column label="盲票组ID" prop="boxId" min-width="100" sortable="custom" />
  128. <el-table-column label="盲票图片" prop="picUrl" min-width="120">
  129. <template slot-scope="scope">
  130. <div>
  131. <el-image
  132. style="width: 70px; height: 80px"
  133. :src="scope.row.picUrl"
  134. :preview-src-list="[scope.row.picUrl]"
  135. />
  136. </div>
  137. </template>
  138. </el-table-column>
  139. <el-table-column label="盲票组名称" prop="title" min-width="85" />
  140. <el-table-column label="盲票组面值" prop="facePrice" min-width="85" sortable="custom" width="110px">
  141. <template slot-scope="scope">
  142. <div>¥{{ $numberFormat(scope.row.facePrice) }}</div>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="盲票总数" prop="quantity" width="100px" sortable="custom">
  146. <template slot-scope="scope">
  147. <div>{{ scope.row.quantity }}张</div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="已售张数" prop="saleQty" min-width="100" sortable="custom">
  151. <template slot-scope="scope">
  152. <div>{{ scope.row.saleQty }}张</div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="盲票类型" prop="type" min-width="80">
  156. <template slot-scope="scope">
  157. {{ scope.row.type.desc }}
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="采购单价" prop="pkgSalePrice" min-width="100" sortable="custom">
  161. <template slot-scope="scope">
  162. <div>¥{{ $numberFormat(scope.row.pkgSalePrice) }}/包</div>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="预付售票价" prop="prePrice" min-width="100" sortable="custom">
  166. <template slot-scope="scope">
  167. <div>¥{{ $numberFormat(scope.row.prePrice) }}/包</div>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="已采购数量" prop="salePkgQty" min-width="110" sortable="custom">
  171. <template slot-scope="scope">
  172. <div>{{ scope.row.salePkgQty }}包</div>
  173. </template>
  174. </el-table-column>
  175. <el-table-column label="状态" prop="status" min-width="80">
  176. <template slot-scope="scope">
  177. <el-tag
  178. :type="scope.row.status.value === 'on' ? 'success' : 'info'"
  179. >{{ scope.row.status.desc }}</el-tag
  180. >
  181. </template>
  182. </el-table-column>
  183. <el-table-column label="排序" prop="sortWeight" sortable="custom" align="center" width="140px">
  184. <template slot-scope="{row, $index}">
  185. <el-input-number v-model="row.sortWeight" @change="handleSortChange($index,row.sortWeight)" controls-position="right" size="small"></el-input-number>
  186. </template>
  187. </el-table-column>
  188. <el-table-column
  189. label="操作"
  190. align="center"
  191. show-overflow-tooltip
  192. class-name="small-padding fixed-width"
  193. min-width="150"
  194. fixed="right"
  195. >
  196. <template slot-scope="scope">
  197. <div>
  198. <el-button
  199. v-hasPermi="['business:ticket:query']"
  200. type="text"
  201. @click="getDetail(scope.row)"
  202. >查看</el-button
  203. >
  204. <el-button
  205. v-hasPermi="['business:ticket:edit']"
  206. type="text"
  207. @click="setDetail(scope.row)"
  208. >编辑</el-button
  209. >
  210. <el-button
  211. v-show="
  212. scope.row.status.value === 'off' ||
  213. scope.row.status.value === 'done'
  214. "
  215. v-hasPermi="['business:ticket:on']"
  216. type="text"
  217. @click="setStatus(scope.row, 'on')"
  218. >上架</el-button
  219. >
  220. <el-button
  221. v-show="scope.row.status.value === 'on'"
  222. v-hasPermi="['business:ticket:on']"
  223. type="text"
  224. @click="setStatus(scope.row, 'off')"
  225. >下架</el-button
  226. >
  227. <el-button
  228. v-show="scope.row.status.value === 'done'"
  229. v-hasPermi="['business:ticket:remove']"
  230. type="text"
  231. class="del"
  232. @click="del(scope.row)"
  233. >删除</el-button
  234. >
  235. </div>
  236. </template>
  237. </el-table-column>
  238. </el-table>
  239. <pagination
  240. v-show="total > 0"
  241. :total="total"
  242. :page.sync="pageParams.pageNum"
  243. :limit.sync="pageParams.pageSize"
  244. @pagination="getList"
  245. />
  246. <!-- 导入 -->
  247. <ticket-import
  248. v-if="importShow"
  249. :dialog-visible="importShow"
  250. @close="hideDialog"
  251. />
  252. </div>
  253. </template>
  254. <script>
  255. import {
  256. getTicketList,
  257. exportTicket,
  258. exportDraw,
  259. ticketBoxPut,
  260. ticketBoxRemove, setListData
  261. } from "@/api/business/ticket";
  262. import { publicFileGetUrl } from "@/api/common";
  263. import TicketImport from "./import";
  264. export default {
  265. name: "Ticket",
  266. components: {
  267. TicketImport,
  268. },
  269. data() {
  270. return {
  271. sortNum:0,
  272. loading: false,
  273. exportLoading: false,
  274. showSearch: true,
  275. queryParams: {
  276. title: "",
  277. type: "",
  278. status: "",
  279. },
  280. pageParams: {
  281. pageNum: 1,
  282. pageSize: 10,
  283. orderByColumn: '',
  284. isAsc: 'desc',
  285. },
  286. // 总条数
  287. total: 0,
  288. list: [],
  289. ids: [],
  290. importShow: false,
  291. };
  292. },
  293. watch: {
  294. $route: {
  295. handler: function (val, oldVal) {
  296. if (val.name == "Ticket") {
  297. this.getList();
  298. }
  299. },
  300. },
  301. },
  302. created() {
  303. this.getList();
  304. },
  305. methods: {
  306. //切换排序
  307. sortChannelId(row){
  308. if (row){
  309. let prop = row.prop == 'channelId' || row.prop == 'commRate' ? ('t1.'+ row.prop) : row.prop;
  310. this.pageParams.orderByColumn = prop
  311. this.pageParams.isAsc = row.order=='ascending'?"asc":"desc";
  312. this.getList()
  313. }
  314. },
  315. //步进器修改
  316. handleSortChange(index,sortWeight){
  317. this.list[index].sortWeight = sortWeight
  318. let data = {
  319. boxId: this.list[index].boxId,
  320. sortWeight: this.list[index].sortWeight
  321. }
  322. setListData(data)
  323. },
  324. // 盲票组列表
  325. getList() {
  326. this.loading = true;
  327. getTicketList( 'pageNum=' + this.pageParams.pageNum + '&pageSize=' + this.pageParams.pageSize + '&orderByColumn='+ this.pageParams.orderByColumn +'&isAsc='+ this.pageParams.isAsc +'&',
  328. this.queryParams
  329. )
  330. .then((res) => {
  331. this.loading = false;
  332. if (res.code == 0) {
  333. res.rows.forEach((item) => {
  334. let picUrlArr = item.picUrl.split(",");
  335. item.picUrl = publicFileGetUrl + picUrlArr[0];
  336. item.status = JSON.parse(item.status);
  337. item.type = JSON.parse(item.type);
  338. });
  339. this.total = res.total;
  340. this.list = res.rows;
  341. }
  342. })
  343. .catch(() => {
  344. this.loading = false;
  345. });
  346. },
  347. setStatus(item, status) {
  348. this.$confirm(
  349. `确认${status === "on" ? "上架" : "下架"}盲票 “${item.title}” 吗?`,
  350. `${status === "on" ? "上架" : "下架"}盲票`,
  351. {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. type: "warning",
  355. }
  356. ).then(() => {
  357. ticketBoxPut({
  358. boxId: item.boxId,
  359. status,
  360. }).then((res) => {
  361. if (res.code === 0) {
  362. this.$message.success("操作已完成!");
  363. this.getList();
  364. }
  365. });
  366. });
  367. },
  368. del(item) {
  369. this.$confirm(`确认删除盲票 “${item.title}” 吗?`, "删除盲票", {
  370. confirmButtonText: "确定",
  371. cancelButtonText: "取消",
  372. type: "warning",
  373. }).then(() => {
  374. ticketBoxRemove({ boxId: item.boxId }).then((res) => {
  375. if (res.code === 0) {
  376. this.$message.success("操作已完成!");
  377. this.getList();
  378. }
  379. });
  380. });
  381. },
  382. // 搜索
  383. handleQuery() {
  384. this.getList();
  385. },
  386. // 重置
  387. resetQuery() {
  388. this.resetForm("queryForm");
  389. this.getList();
  390. },
  391. // 添加盲票组
  392. handleAdd() {
  393. this.$router.push({ name: "TicketCreate" });
  394. },
  395. handleSelect(selection, row) {
  396. const isSelect = selection.find((item) => item.boxId === row.boxId);
  397. this.$refs.table.clearSelection();
  398. if (isSelect) {
  399. this.$refs.table.toggleRowSelection(row, true);
  400. this.ids = row.boxId;
  401. } else {
  402. this.ids = "";
  403. }
  404. },
  405. // 查看详情
  406. getDetail(row) {
  407. this.$router.push({ name: "TicketDetail", query: { id: row.boxId } });
  408. },
  409. // 编辑信息
  410. setDetail(row) {
  411. this.$router.push({ name: "TicketEdit", query: { id: row.boxId } });
  412. },
  413. handleDetail() {},
  414. handleImport() {
  415. this.importShow = true;
  416. },
  417. hideDialog() {
  418. this.importShow = false;
  419. },
  420. /** 导出按钮操作 */
  421. handleExport() {
  422. const boxIds = this.ids || [];
  423. if (boxIds.length == 0) {
  424. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  425. } else {
  426. this.$confirm("是否确认导出所选盲票数据项?", "警告", {
  427. confirmButtonText: "确定",
  428. cancelButtonText: "取消",
  429. type: "warning",
  430. })
  431. .then(() => {
  432. this.vloading = this.$loading({
  433. lock: true,
  434. text: "正在导出.....",
  435. background: "rgba(0, 0, 0, 0.7)",
  436. });
  437. return exportTicket({ ids: boxIds });
  438. })
  439. .then((response) => {
  440. this.vloading.close();
  441. this.download(response.msg);
  442. this.exportLoading = false;
  443. })
  444. .catch(() => {
  445. this.vloading.close();
  446. this.exportLoading = false;
  447. });
  448. }
  449. },
  450. /** 导出按钮操作 */
  451. handleExportDraw() {
  452. const boxIds = this.ids || [];
  453. if (boxIds.length == 0) {
  454. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  455. } else {
  456. this.$confirm("是否确认导出所选盲票数据项?", "提示", {
  457. confirmButtonText: "确定",
  458. cancelButtonText: "取消",
  459. type: "warning",
  460. })
  461. .then(() => {
  462. this.vloading = this.$loading({
  463. lock: true,
  464. text: "正在导出印刷.....",
  465. background: "rgba(0, 0, 0, 0.7)",
  466. });
  467. return exportDraw({ ids: boxIds });
  468. })
  469. .then((response) => {
  470. this.vloading.close();
  471. this.download(response.msg);
  472. this.exportLoading = false;
  473. })
  474. .catch(() => {
  475. this.vloading.close();
  476. this.exportLoading = false;
  477. });
  478. }
  479. },
  480. },
  481. mounted() {},
  482. destroyed() {},
  483. };
  484. </script>
  485. <style lang="scss">
  486. .ticket-table {
  487. thead {
  488. .el-checkbox {
  489. display: none !important;
  490. }
  491. }
  492. }
  493. </style>