index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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="盲票组名称">
  11. <el-input
  12. v-model="queryParams.title"
  13. placeholder="请输入盲票组名称"
  14. clearable
  15. size="small"
  16. style="width: 240px"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="盲票组类型">
  21. <el-select
  22. v-model="queryParams.type"
  23. placeholder="请选择盲票组类型"
  24. clearable
  25. size="small"
  26. @change="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="盲票组状态">
  34. <el-select
  35. v-model="queryParams.status"
  36. placeholder="请选择盲票组状态"
  37. clearable
  38. size="small"
  39. @change="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="handleQuery"
  55. >搜索</el-button
  56. >
  57. <el-button icon="el-icon-refresh" size="mini" @click="getList(true)"
  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"
  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="80" />
  127. <el-table-column label="盲票图片" prop="picUrl" min-width="100">
  128. <template slot-scope="scope">
  129. <div>
  130. <el-image
  131. style="width: 100px; height: 100px"
  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">
  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="90">
  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="90">
  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="90">
  160. <template slot-scope="scope">
  161. <div>¥{{ $numberFormat(scope.row.pkgSalePrice) }}/包</div>
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="已采购数量" prop="salePkgQty" min-width="90">
  165. <template slot-scope="scope">
  166. <div>{{ scope.row.salePkgQty }}包</div>
  167. </template>
  168. </el-table-column>
  169. <el-table-column label="状态" prop="status" min-width="80">
  170. <template slot-scope="scope">
  171. <el-tag
  172. :type="scope.row.status.value === 'on' ? 'success' : 'info'"
  173. >{{ scope.row.status.desc }}</el-tag
  174. >
  175. </template>
  176. </el-table-column>
  177. <el-table-column
  178. label="操作"
  179. align="center"
  180. show-overflow-tooltip
  181. class-name="small-padding fixed-width"
  182. min-width="150"
  183. fixed="right"
  184. >
  185. <template slot-scope="scope">
  186. <div>
  187. <el-button
  188. v-if="
  189. scope.row.status.value === 'off' ||
  190. scope.row.status.value === 'done'
  191. "
  192. v-hasPermi="['business:ticket:on']"
  193. type="text"
  194. @click="setStatus(scope.row, 'on')"
  195. >上架</el-button
  196. >
  197. <el-button
  198. v-if="scope.row.status.value === 'on'"
  199. v-hasPermi="['business:ticket:on']"
  200. type="text"
  201. @click="setStatus(scope.row, 'off')"
  202. >下架</el-button
  203. >
  204. <el-button
  205. v-if="scope.row.status.value === 'done'"
  206. v-hasPermi="['business:ticket:remove']"
  207. type="text"
  208. class="del"
  209. @click="del(scope.row)"
  210. >删除</el-button
  211. >
  212. </div>
  213. </template>
  214. </el-table-column>
  215. </el-table>
  216. <pagination
  217. v-show="total > 0"
  218. :total="total"
  219. :page.sync="pageParams.pageNum"
  220. :limit.sync="pageParams.pageSize"
  221. @pagination="getList"
  222. />
  223. <!-- 导入 -->
  224. <ticket-import
  225. v-if="importShow"
  226. :dialog-visible="importShow"
  227. @close="hideDialog"
  228. />
  229. </div>
  230. </template>
  231. <script>
  232. import {
  233. getTicketList,
  234. exportTicket,
  235. exportDraw,
  236. ticketBoxPut,
  237. ticketBoxRemove,
  238. } from "@/api/business/ticket";
  239. import { publicFileGetUrl } from "@/api/common";
  240. import TicketImport from "./import";
  241. export default {
  242. name: "Ticket",
  243. components: {
  244. TicketImport,
  245. },
  246. data() {
  247. return {
  248. loading: false,
  249. exportLoading: false,
  250. showSearch: true,
  251. queryParams: {
  252. title: "",
  253. type: "",
  254. status: "",
  255. },
  256. pageParams: {
  257. pageNum: 1,
  258. pageSize: 10,
  259. },
  260. // 总条数
  261. total: 0,
  262. list: [],
  263. ids: [],
  264. importShow: false,
  265. };
  266. },
  267. watch: {
  268. $route: {
  269. handler: function(val, oldVal){
  270. if(val.name == 'Ticket'){
  271. this.getList();
  272. }
  273. }
  274. }
  275. },
  276. created() {
  277. this.getList();
  278. },
  279. methods: {
  280. // 盲票组列表
  281. getList(reset) {
  282. if (this.loading) {
  283. return
  284. }
  285. this.loading = true
  286. if (reset) {
  287. this.queryParams = { pageNum: 1, pageSize: 20 }
  288. }
  289. getTicketList(
  290. "pageNum=" +
  291. this.pageParams.pageNum +
  292. "&pageSize=" +
  293. this.pageParams.pageSize +
  294. "&",
  295. this.queryParams
  296. )
  297. .then((res) => {
  298. this.loading = false;
  299. if (res.code == 0) {
  300. res.rows.forEach((item) => {
  301. let picUrlArr = item.picUrl.split(",");
  302. item.picUrl = publicFileGetUrl + picUrlArr[0];
  303. item.status = JSON.parse(item.status);
  304. item.type = JSON.parse(item.type);
  305. });
  306. this.total = res.total;
  307. this.list = res.rows;
  308. }
  309. })
  310. .catch(() => {
  311. this.loading = false;
  312. });
  313. },
  314. setStatus(item, status) {
  315. this.$confirm(
  316. `确认${status === "on" ? "上架" : "下架"}盲票 “${item.title}” 吗?`,
  317. `${status === "on" ? "上架" : "下架"}盲票`,
  318. {
  319. confirmButtonText: "确定",
  320. cancelButtonText: "取消",
  321. type: "warning",
  322. }
  323. ).then(() => {
  324. ticketBoxPut({
  325. boxId: item.boxId,
  326. status,
  327. }).then((res) => {
  328. if (res.code === 0) {
  329. this.$message.success("操作已完成!");
  330. this.getList();
  331. }
  332. });
  333. });
  334. },
  335. del(item) {
  336. this.$confirm(`确认删除盲票 “${item.title}” 吗?`, "删除盲票", {
  337. confirmButtonText: "确定",
  338. cancelButtonText: "取消",
  339. type: "warning",
  340. }).then(() => {
  341. ticketBoxRemove({ boxId: item.boxId }).then((res) => {
  342. if (res.code === 0) {
  343. this.$message.success("操作已完成!");
  344. this.getList();
  345. }
  346. });
  347. });
  348. },
  349. // 搜索
  350. handleQuery() {
  351. this.getList();
  352. },
  353. // 重置
  354. resetQuery() {
  355. },
  356. // 添加盲票组
  357. handleAdd() {
  358. this.$router.push({ name: "TicketCreate" });
  359. },
  360. handleSelect(selection, row) {
  361. const isSelect = selection.find((item) => item.boxId === row.boxId);
  362. this.$refs.table.clearSelection();
  363. if (isSelect) {
  364. this.$refs.table.toggleRowSelection(row, true);
  365. this.ids = row.boxId;
  366. } else {
  367. this.ids = "";
  368. }
  369. },
  370. handleDetail() {},
  371. handleImport() {
  372. console.log("handleImport ====================");
  373. this.importShow = true;
  374. },
  375. hideDialog() {
  376. this.importShow = false;
  377. },
  378. /** 导出按钮操作 */
  379. handleExport() {
  380. const boxIds = this.ids || [];
  381. if (boxIds.length == 0) {
  382. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  383. } else {
  384. this.$confirm("是否确认导出所选盲票数据项?", "警告", {
  385. confirmButtonText: "确定",
  386. cancelButtonText: "取消",
  387. type: "warning",
  388. })
  389. .then(() => {
  390. this.vloading = this.$loading({
  391. lock: true,
  392. text: "正在导出.....",
  393. background: "rgba(0, 0, 0, 0.7)",
  394. });
  395. return exportTicket({ ids: boxIds });
  396. })
  397. .then((response) => {
  398. this.vloading.close();
  399. this.download(response.msg);
  400. this.exportLoading = false;
  401. })
  402. .catch(() => {
  403. this.vloading.close();
  404. this.exportLoading = false;
  405. });
  406. }
  407. },
  408. /** 导出按钮操作 */
  409. handleExportDraw() {
  410. const boxIds = this.ids || [];
  411. if (boxIds.length == 0) {
  412. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  413. } else {
  414. this.$confirm("是否确认导出所选盲票数据项?", "警告", {
  415. confirmButtonText: "确定",
  416. cancelButtonText: "取消",
  417. type: "warning",
  418. })
  419. .then(() => {
  420. this.vloading = this.$loading({
  421. lock: true,
  422. text: "正在导出印刷.....",
  423. background: "rgba(0, 0, 0, 0.7)",
  424. });
  425. return exportDraw({ ids: boxIds });
  426. })
  427. .then((response) => {
  428. this.vloading.close();
  429. this.download(response.msg);
  430. this.exportLoading = false;
  431. })
  432. .catch(() => {
  433. this.vloading.close();
  434. this.exportLoading = false;
  435. });
  436. }
  437. },
  438. },
  439. mounted() {},
  440. destroyed() {},
  441. };
  442. </script>
  443. <style lang="scss">
  444. .ticket-table {
  445. thead {
  446. .el-checkbox {
  447. display: none !important;
  448. }
  449. }
  450. }
  451. </style>