index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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. <right-toolbar
  100. :showSearch.sync="showSearch"
  101. @queryTable="getList"
  102. ></right-toolbar>
  103. </el-row>
  104. <el-table
  105. ref="table"
  106. v-loading="loading"
  107. :data="list"
  108. @select="handleSelect"
  109. class="ticket-table"
  110. >
  111. <el-table-column
  112. type="selection"
  113. width="55"
  114. align="center"
  115. fixed="left"
  116. />
  117. <el-table-column label="盲票组ID" prop="boxId" min-width="80" />
  118. <el-table-column label="盲票图片" prop="picUrl" min-width="100">
  119. <template slot-scope="scope">
  120. <div>
  121. <el-image
  122. style="width: 100px; height: 100px"
  123. :src="scope.row.picUrl"
  124. :preview-src-list="[scope.row.picUrl]"
  125. />
  126. </div>
  127. </template>
  128. </el-table-column>
  129. <el-table-column label="盲票组名称" prop="title" min-width="85" />
  130. <el-table-column label="盲票组面值" prop="facePrice" min-width="85">
  131. <template slot-scope="scope">
  132. <div>¥{{ $numberFormat(scope.row.facePrice) }}</div>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="盲票总数" prop="quantity" width="90">
  136. <template slot-scope="scope">
  137. <div>{{ scope.row.quantity }}张</div>
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="已售张数" prop="saleQty" min-width="90">
  141. <template slot-scope="scope">
  142. <div>{{ scope.row.saleQty }}张</div>
  143. </template>
  144. </el-table-column>
  145. <el-table-column label="盲票类型" prop="type" min-width="80">
  146. <template slot-scope="scope">
  147. {{ scope.row.type.desc }}
  148. </template>
  149. </el-table-column>
  150. <el-table-column label="采购单价" prop="pkgSalePrice" min-width="90">
  151. <template slot-scope="scope">
  152. <div>¥{{ $numberFormat(scope.row.pkgSalePrice) }}/包</div>
  153. </template>
  154. </el-table-column>
  155. <el-table-column label="已采购数量" prop="salePkgQty" min-width="90">
  156. <template slot-scope="scope">
  157. <div>{{ scope.row.salePkgQty }}张</div>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="状态" prop="status" min-width="80">
  161. <template slot-scope="scope">
  162. <el-tag
  163. :type="scope.row.status.value === 'on' ? 'success' : 'info'"
  164. >{{ scope.row.status.desc }}</el-tag
  165. >
  166. </template>
  167. </el-table-column>
  168. <el-table-column
  169. label="操作"
  170. align="center"
  171. show-overflow-tooltip
  172. class-name="small-padding fixed-width"
  173. min-width="150"
  174. fixed="right"
  175. >
  176. <template slot-scope="scope">
  177. <div>
  178. <el-button
  179. v-if="
  180. scope.row.status.value === 'off' ||
  181. scope.row.status.value === 'done'
  182. "
  183. v-hasPermi="['business:ticket:on']"
  184. type="text"
  185. @click="setStatus(scope.row, 'on')"
  186. >上架</el-button
  187. >
  188. <el-button
  189. v-if="scope.row.status.value === 'on'"
  190. v-hasPermi="['business:ticket:off']"
  191. type="text"
  192. @click="setStatus(scope.row, 'off')"
  193. >下架</el-button
  194. >
  195. <el-button
  196. v-if="scope.row.status.value === 'done'"
  197. v-hasPermi="['business:ticket:remove']"
  198. type="text"
  199. class="del"
  200. @click="del(scope.row)"
  201. >删除</el-button
  202. >
  203. </div>
  204. </template>
  205. </el-table-column>
  206. </el-table>
  207. <pagination
  208. v-show="total > 0"
  209. :total="total"
  210. :page.sync="pageParams.pageNum"
  211. :limit.sync="pageParams.pageSize"
  212. @pagination="getList"
  213. />
  214. <!-- 导入 -->
  215. <ticket-import
  216. v-if="importShow"
  217. :dialog-visible="importShow"
  218. @close="hideDialog"
  219. />
  220. </div>
  221. </template>
  222. <script>
  223. import {
  224. getTicketList,
  225. exportTicket,
  226. ticketBoxPut,
  227. ticketBoxRemove,
  228. } from "@/api/business/ticket";
  229. import { publicFileGetUrl } from "@/api/common";
  230. import TicketImport from "./import";
  231. export default {
  232. name: "Ticket",
  233. components: {
  234. TicketImport,
  235. },
  236. data() {
  237. return {
  238. loading: false,
  239. exportLoading: false,
  240. showSearch: true,
  241. queryParams: {
  242. title: "",
  243. ticketType: "",
  244. ticketState: "",
  245. },
  246. pageParams: {
  247. pageNum: 1,
  248. pageSize: 10,
  249. },
  250. ticketTypeArr: [],
  251. ticketStateArr: [],
  252. // 总条数
  253. total: 0,
  254. list: [],
  255. ids: [],
  256. importShow: false,
  257. };
  258. },
  259. created() {
  260. this.getList();
  261. },
  262. methods: {
  263. // 盲票组列表
  264. getList() {
  265. this.loading = true;
  266. getTicketList(
  267. "pageNum=" +
  268. this.pageParams.pageNum +
  269. "&pageSize=" +
  270. this.pageParams.pageSize +
  271. "&",
  272. this.queryParams
  273. )
  274. .then((res) => {
  275. this.loading = false;
  276. if (res.code == 0) {
  277. res.rows.forEach((item) => {
  278. let picUrlArr = item.picUrl.split(",");
  279. item.picUrl = publicFileGetUrl + picUrlArr[0];
  280. item.status = JSON.parse(item.status);
  281. item.type = JSON.parse(item.type);
  282. });
  283. this.total = res.total;
  284. this.list = res.rows;
  285. }
  286. })
  287. .catch(() => {
  288. this.loading = false;
  289. });
  290. },
  291. setStatus(item, status) {
  292. this.$confirm(
  293. `确认${status === "on" ? "上架" : "下架"}盲票 “${item.title}” 吗?`,
  294. `${status === "on" ? "上架" : "下架"}盲票`,
  295. {
  296. confirmButtonText: "确定",
  297. cancelButtonText: "取消",
  298. type: "warning",
  299. }
  300. ).then(() => {
  301. ticketBoxPut({
  302. boxId: item.boxId,
  303. status,
  304. }).then((res) => {
  305. if (res.code === 0) {
  306. this.$message.success("操作已完成!");
  307. this.getList();
  308. }
  309. });
  310. });
  311. },
  312. del(item) {
  313. this.$confirm(`确认删除盲票 “${item.title}” 吗?`, "删除盲票", {
  314. confirmButtonText: "确定",
  315. cancelButtonText: "取消",
  316. type: "warning",
  317. }).then(() => {
  318. ticketBoxRemove({ boxId: item.boxId }).then((res) => {
  319. if (res.code === 0) {
  320. this.$message.success("操作已完成!");
  321. this.getList();
  322. }
  323. });
  324. });
  325. },
  326. // 搜索
  327. handleQuery() {
  328. this.getList();
  329. },
  330. // 重置
  331. resetQuery() {},
  332. // 添加盲票组
  333. handleAdd() {
  334. this.$router.push({ name: "TicketCreate" });
  335. },
  336. handleSelect(selection, row) {
  337. const isSelect = selection.find((item) => item.boxId === row.boxId);
  338. this.$refs.table.clearSelection();
  339. if (isSelect) {
  340. this.$refs.table.toggleRowSelection(row, true);
  341. this.ids = row.boxId;
  342. } else {
  343. this.ids = "";
  344. }
  345. },
  346. handleDetail() {},
  347. handleImport() {
  348. console.log("handleImport ====================");
  349. this.importShow = true;
  350. },
  351. hideDialog() {
  352. this.importShow = false;
  353. },
  354. /** 导出按钮操作 */
  355. handleExport() {
  356. const boxIds = this.ids || [];
  357. if (boxIds.length == 0) {
  358. this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
  359. } else {
  360. this.$confirm("是否确认导出所选盲票数据项?", "警告", {
  361. confirmButtonText: "确定",
  362. cancelButtonText: "取消",
  363. type: "warning",
  364. })
  365. .then(() => {
  366. this.exportLoading = true;
  367. return exportTicket({ ids: boxIds });
  368. })
  369. .then((response) => {
  370. this.download(response.msg);
  371. this.exportLoading = false;
  372. })
  373. .catch(() => {
  374. this.exportLoading = false;
  375. });
  376. }
  377. },
  378. },
  379. mounted() {},
  380. destroyed() {},
  381. };
  382. </script>
  383. <style lang="scss">
  384. .ticket-table {
  385. thead {
  386. .el-checkbox {
  387. display: none !important;
  388. }
  389. }
  390. }
  391. </style>