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