index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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: 110px; height: 150px"
  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="salePkgQty" min-width="110" sortable="custom">
  166. <template slot-scope="scope">
  167. <div>{{ scope.row.salePkgQty }}包</div>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="状态" prop="status" min-width="80">
  171. <template slot-scope="scope">
  172. <el-tag
  173. :type="scope.row.status.value === 'on' ? 'success' : 'info'"
  174. >{{ scope.row.status.desc }}</el-tag
  175. >
  176. </template>
  177. </el-table-column>
  178. <el-table-column label="排序" prop="sortWeight" sortable="custom" align="center" width="140px">
  179. <template slot-scope="{row, $index}">
  180. <el-input-number v-model="row.sortWeight" @change="handleSortChange($index,row.sortWeight)" controls-position="right" size="small"></el-input-number>
  181. </template>
  182. </el-table-column>
  183. <el-table-column
  184. label="操作"
  185. align="center"
  186. show-overflow-tooltip
  187. class-name="small-padding fixed-width"
  188. min-width="150"
  189. fixed="right"
  190. >
  191. <template slot-scope="scope">
  192. <div>
  193. <el-button
  194. v-hasPermi="['business:ticket:query']"
  195. type="text"
  196. @click="getDetail(scope.row)"
  197. >查看</el-button
  198. >
  199. <el-button
  200. v-hasPermi="['business:ticket:edit']"
  201. type="text"
  202. @click="setDetail(scope.row)"
  203. >编辑</el-button
  204. >
  205. <el-button
  206. v-show="
  207. scope.row.status.value === 'off' ||
  208. scope.row.status.value === 'done'
  209. "
  210. v-hasPermi="['business:ticket:on']"
  211. type="text"
  212. @click="setStatus(scope.row, 'on')"
  213. >上架</el-button
  214. >
  215. <el-button
  216. v-show="scope.row.status.value === 'on'"
  217. v-hasPermi="['business:ticket:on']"
  218. type="text"
  219. @click="setStatus(scope.row, 'off')"
  220. >下架</el-button
  221. >
  222. <el-button
  223. v-show="scope.row.status.value === 'done'"
  224. v-hasPermi="['business:ticket:remove']"
  225. type="text"
  226. class="del"
  227. @click="del(scope.row)"
  228. >删除</el-button
  229. >
  230. </div>
  231. </template>
  232. </el-table-column>
  233. </el-table>
  234. <pagination
  235. v-show="total > 0"
  236. :total="total"
  237. :page.sync="pageParams.pageNum"
  238. :limit.sync="pageParams.pageSize"
  239. @pagination="getList"
  240. />
  241. <!-- 导入 -->
  242. <ticket-import
  243. v-if="importShow"
  244. :dialog-visible="importShow"
  245. @close="hideDialog"
  246. />
  247. </div>
  248. </template>
  249. <script>
  250. import {
  251. getTicketList,
  252. exportTicket,
  253. exportDraw,
  254. ticketBoxPut,
  255. ticketBoxRemove, setListData
  256. } from "@/api/business/ticket";
  257. import { publicFileGetUrl } from "@/api/common";
  258. import TicketImport from "./import";
  259. export default {
  260. name: "Ticket",
  261. components: {
  262. TicketImport,
  263. },
  264. data() {
  265. return {
  266. sortNum:0,
  267. loading: false,
  268. exportLoading: false,
  269. showSearch: true,
  270. queryParams: {
  271. title: "",
  272. type: "",
  273. status: "",
  274. },
  275. pageParams: {
  276. pageNum: 1,
  277. pageSize: 10,
  278. orderByColumn: '',
  279. isAsc: 'desc',
  280. },
  281. // 总条数
  282. total: 0,
  283. list: [],
  284. ids: [],
  285. importShow: false,
  286. };
  287. },
  288. watch: {
  289. $route: {
  290. handler: function (val, oldVal) {
  291. if (val.name == "Ticket") {
  292. this.getList();
  293. }
  294. },
  295. },
  296. },
  297. created() {
  298. this.getList();
  299. },
  300. methods: {
  301. //切换排序
  302. sortChannelId(row){
  303. if (row){
  304. let prop = row.prop == 'channelId' || row.prop == 'commRate' ? ('t1.'+ row.prop) : row.prop;
  305. this.pageParams.orderByColumn = prop
  306. this.pageParams.isAsc = row.order=='ascending'?"asc":"desc";
  307. this.getList()
  308. }
  309. },
  310. //步进器修改
  311. handleSortChange(index,sortWeight){
  312. this.list[index].sortWeight = sortWeight
  313. let data = {
  314. boxId: this.list[index].boxId,
  315. sortWeight: this.list[index].sortWeight
  316. }
  317. setListData(data)
  318. },
  319. // 盲票组列表
  320. getList(reset) {
  321. this.loading = true;
  322. getTicketList( 'pageNum=' + this.pageParams.pageNum + '&pageSize=' + this.pageParams.pageSize + '&orderByColumn='+ this.pageParams.orderByColumn +'&isAsc='+ this.pageParams.isAsc +'&',
  323. this.queryParams
  324. )
  325. .then((res) => {
  326. this.loading = false;
  327. if (res.code == 0) {
  328. res.rows.forEach((item) => {
  329. let picUrlArr = item.picUrl.split(",");
  330. item.picUrl = publicFileGetUrl + picUrlArr[0];
  331. item.status = JSON.parse(item.status);
  332. item.type = JSON.parse(item.type);
  333. });
  334. this.total = res.total;
  335. this.list = res.rows;
  336. }
  337. })
  338. .catch(() => {
  339. this.loading = false;
  340. });
  341. },
  342. setStatus(item, status) {
  343. this.$confirm(
  344. `确认${status === "on" ? "上架" : "下架"}盲票 “${item.title}” 吗?`,
  345. `${status === "on" ? "上架" : "下架"}盲票`,
  346. {
  347. confirmButtonText: "确定",
  348. cancelButtonText: "取消",
  349. type: "warning",
  350. }
  351. ).then(() => {
  352. ticketBoxPut({
  353. boxId: item.boxId,
  354. status,
  355. }).then((res) => {
  356. if (res.code === 0) {
  357. this.$message.success("操作已完成!");
  358. this.getList();
  359. }
  360. });
  361. });
  362. },
  363. del(item) {
  364. this.$confirm(`确认删除盲票 “${item.title}” 吗?`, "删除盲票", {
  365. confirmButtonText: "确定",
  366. cancelButtonText: "取消",
  367. type: "warning",
  368. }).then(() => {
  369. ticketBoxRemove({ boxId: item.boxId }).then((res) => {
  370. if (res.code === 0) {
  371. this.$message.success("操作已完成!");
  372. this.getList();
  373. }
  374. });
  375. });
  376. },
  377. // 搜索
  378. handleQuery() {
  379. this.getList();
  380. },
  381. // 重置
  382. resetQuery() {
  383. this.resetForm("queryForm");
  384. this.getList();
  385. },
  386. // 添加盲票组
  387. handleAdd() {
  388. this.$router.push({ name: "TicketCreate" });
  389. },
  390. handleSelect(selection, row) {
  391. const isSelect = selection.find((item) => item.boxId === row.boxId);
  392. this.$refs.table.clearSelection();
  393. if (isSelect) {
  394. this.$refs.table.toggleRowSelection(row, true);
  395. this.ids = row.boxId;
  396. } else {
  397. this.ids = "";
  398. }
  399. },
  400. // 查看详情
  401. getDetail(row) {
  402. this.$router.push({ name: "TicketDetail", query: { id: row.boxId } });
  403. },
  404. // 编辑信息
  405. setDetail(row) {
  406. this.$router.push({ name: "TicketEdit", query: { id: row.boxId } });
  407. },
  408. handleDetail() {},
  409. handleImport() {
  410. console.log("handleImport ====================");
  411. this.importShow = true;
  412. },
  413. hideDialog() {
  414. this.importShow = false;
  415. },
  416. /** 导出按钮操作 */
  417. handleExport() {
  418. const boxIds = this.ids || [];
  419. if (boxIds.length == 0) {
  420. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  421. } else {
  422. this.$confirm("是否确认导出所选盲票数据项?", "警告", {
  423. confirmButtonText: "确定",
  424. cancelButtonText: "取消",
  425. type: "warning",
  426. })
  427. .then(() => {
  428. this.vloading = this.$loading({
  429. lock: true,
  430. text: "正在导出.....",
  431. background: "rgba(0, 0, 0, 0.7)",
  432. });
  433. return exportTicket({ ids: boxIds });
  434. })
  435. .then((response) => {
  436. this.vloading.close();
  437. this.download(response.msg);
  438. this.exportLoading = false;
  439. })
  440. .catch(() => {
  441. this.vloading.close();
  442. this.exportLoading = false;
  443. });
  444. }
  445. },
  446. /** 导出按钮操作 */
  447. handleExportDraw() {
  448. const boxIds = this.ids || [];
  449. if (boxIds.length == 0) {
  450. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  451. } else {
  452. this.$confirm("是否确认导出所选盲票数据项?", "警告", {
  453. confirmButtonText: "确定",
  454. cancelButtonText: "取消",
  455. type: "warning",
  456. })
  457. .then(() => {
  458. this.vloading = this.$loading({
  459. lock: true,
  460. text: "正在导出印刷.....",
  461. background: "rgba(0, 0, 0, 0.7)",
  462. });
  463. return exportDraw({ ids: boxIds });
  464. })
  465. .then((response) => {
  466. this.vloading.close();
  467. this.download(response.msg);
  468. this.exportLoading = false;
  469. })
  470. .catch(() => {
  471. this.vloading.close();
  472. this.exportLoading = false;
  473. });
  474. }
  475. },
  476. },
  477. mounted() {},
  478. destroyed() {},
  479. };
  480. </script>
  481. <style lang="scss">
  482. .ticket-table {
  483. thead {
  484. .el-checkbox {
  485. display: none !important;
  486. }
  487. }
  488. }
  489. </style>