index.vue 13 KB

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