index.vue 12 KB

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