123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- <template>
- <div class="app-container">
- <el-form
- :model="queryParams"
- ref="queryForm"
- :inline="true"
- v-show="showSearch"
- label-width="90px"
- >
- <el-form-item label="盲票组名称">
- <el-input
- v-model="queryParams.title"
- placeholder="请输入盲票组名称"
- clearable
- size="small"
- style="width: 240px"
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="盲票组类型">
- <el-select
- v-model="queryParams.ticketType"
- placeholder="请选择盲票组类型"
- clearable
- size="small"
- @change="handleQuery"
- >
- <el-option
- v-for="item in ticketTypeArr"
- :key="item.areaId"
- :label="item.areaName"
- :value="item.areaId"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="盲票组状态">
- <el-select
- v-model="queryParams.ticketState"
- placeholder="请选择盲票组状态"
- clearable
- size="small"
- @change="handleQuery"
- >
- <el-option
- v-for="item in ticketStateArr"
- :key="item.areaId"
- :label="item.areaName"
- :value="item.areaId"
- />
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- icon="el-icon-search"
- size="mini"
- @click="handleQuery"
- >搜索</el-button
- >
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
- >重置</el-button
- >
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="primary"
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['business:ticket:add']"
- >添加盲票组</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="info"
- plain
- icon="el-icon-upload2"
- size="mini"
- @click="handleImport"
- v-hasPermi="['business:ticket:import']"
- >导入</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- :loading="exportLoading"
- @click="handleExport"
- v-hasPermi="['business:ticket:export']"
- >导出</el-button
- >
- </el-col>
- <right-toolbar
- :showSearch.sync="showSearch"
- @queryTable="getList"
- ></right-toolbar>
- </el-row>
- <el-table
- ref="table"
- v-loading="loading"
- :data="list"
- @select="handleSelect"
- class="ticket-table"
- >
- <el-table-column
- type="selection"
- width="55"
- align="center"
- fixed="left"
- />
- <el-table-column label="盲票组ID" prop="boxId" min-width="80" />
- <el-table-column label="盲票图片" prop="picUrl" min-width="100">
- <template slot-scope="scope">
- <div>
- <el-image
- style="width: 100px; height: 100px"
- :src="scope.row.picUrl"
- :preview-src-list="[scope.row.picUrl]"
- />
- </div>
- </template>
- </el-table-column>
- <el-table-column label="盲票组名称" prop="title" min-width="85" />
- <el-table-column label="盲票组面值" prop="facePrice" min-width="85">
- <template slot-scope="scope">
- <div>¥{{ $numberFormat(scope.row.facePrice) }}</div>
- </template>
- </el-table-column>
- <el-table-column label="盲票总数" prop="quantity" width="90">
- <template slot-scope="scope">
- <div>{{ scope.row.quantity }}张</div>
- </template>
- </el-table-column>
- <el-table-column label="已售张数" prop="saleQty" min-width="90">
- <template slot-scope="scope">
- <div>{{ scope.row.saleQty }}张</div>
- </template>
- </el-table-column>
- <el-table-column label="盲票类型" prop="type" min-width="80">
- <template slot-scope="scope">
- {{ scope.row.type.desc }}
- </template>
- </el-table-column>
- <el-table-column label="采购单价" prop="pkgSalePrice" min-width="90">
- <template slot-scope="scope">
- <div>¥{{ $numberFormat(scope.row.pkgSalePrice) }}/包</div>
- </template>
- </el-table-column>
- <el-table-column label="已采购数量" prop="salePkgQty" min-width="90">
- <template slot-scope="scope">
- <div>{{ scope.row.salePkgQty }}张</div>
- </template>
- </el-table-column>
- <el-table-column label="状态" prop="status" min-width="80">
- <template slot-scope="scope">
- <el-tag
- :type="scope.row.status.value === 'on' ? 'success' : 'info'"
- >{{ scope.row.status.desc }}</el-tag
- >
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- show-overflow-tooltip
- class-name="small-padding fixed-width"
- min-width="150"
- fixed="right"
- >
- <template slot-scope="scope">
- <div>
- <el-button
- v-if="
- scope.row.status.value === 'off' ||
- scope.row.status.value === 'done'
- "
- v-hasPermi="['business:ticket:on']"
- type="text"
- @click="setStatus(scope.row, 'on')"
- >上架</el-button
- >
- <el-button
- v-if="scope.row.status.value === 'on'"
- v-hasPermi="['business:ticket:off']"
- type="text"
- @click="setStatus(scope.row, 'off')"
- >下架</el-button
- >
- <el-button
- v-if="scope.row.status.value === 'done'"
- v-hasPermi="['business:ticket:remove']"
- type="text"
- class="del"
- @click="del(scope.row)"
- >删除</el-button
- >
- </div>
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="pageParams.pageNum"
- :limit.sync="pageParams.pageSize"
- @pagination="getList"
- />
- <!-- 导入 -->
- <ticket-import
- v-if="importShow"
- :dialog-visible="importShow"
- @close="hideDialog"
- />
- </div>
- </template>
- <script>
- import {
- getTicketList,
- exportTicket,
- ticketBoxPut,
- ticketBoxRemove,
- } from "@/api/business/ticket";
- import { publicFileGetUrl } from "@/api/common";
- import TicketImport from "./import";
- export default {
- name: "Ticket",
- components: {
- TicketImport,
- },
- data() {
- return {
- loading: false,
- exportLoading: false,
- showSearch: true,
- queryParams: {
- title: "",
- ticketType: "",
- ticketState: "",
- },
- pageParams: {
- pageNum: 1,
- pageSize: 10,
- },
- ticketTypeArr: [],
- ticketStateArr: [],
- // 总条数
- total: 0,
- list: [],
- ids: [],
- importShow: false,
- };
- },
- created() {
- this.getList();
- },
- methods: {
- // 盲票组列表
- getList() {
- this.loading = true;
- getTicketList(
- "pageNum=" +
- this.pageParams.pageNum +
- "&pageSize=" +
- this.pageParams.pageSize +
- "&",
- this.queryParams
- )
- .then((res) => {
- this.loading = false;
- if (res.code == 0) {
- res.rows.forEach((item) => {
- let picUrlArr = item.picUrl.split(",");
- item.picUrl = publicFileGetUrl + picUrlArr[0];
- item.status = JSON.parse(item.status);
- item.type = JSON.parse(item.type);
- });
- this.total = res.total;
- this.list = res.rows;
- }
- })
- .catch(() => {
- this.loading = false;
- });
- },
- setStatus(item, status) {
- this.$confirm(
- `确认${status === "on" ? "上架" : "下架"}盲票 “${item.title}” 吗?`,
- `${status === "on" ? "上架" : "下架"}盲票`,
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- ).then(() => {
- ticketBoxPut({
- boxId: item.boxId,
- status,
- }).then((res) => {
- if (res.code === 0) {
- this.$message.success("操作已完成!");
- this.getList();
- }
- });
- });
- },
- del(item) {
- this.$confirm(`确认删除盲票 “${item.title}” 吗?`, "删除盲票", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- ticketBoxRemove({ boxId: item.boxId }).then((res) => {
- if (res.code === 0) {
- this.$message.success("操作已完成!");
- this.getList();
- }
- });
- });
- },
- // 搜索
- handleQuery() {
- this.getList();
- },
- // 重置
- resetQuery() {},
- // 添加盲票组
- handleAdd() {
- this.$router.push({ name: "TicketCreate" });
- },
- handleSelect(selection, row) {
- const isSelect = selection.find((item) => item.boxId === row.boxId);
- this.$refs.table.clearSelection();
- if (isSelect) {
- this.$refs.table.toggleRowSelection(row, true);
- this.ids = row.boxId;
- } else {
- this.ids = "";
- }
- },
- handleDetail() {},
- handleImport() {
- console.log("handleImport ====================");
- this.importShow = true;
- },
- hideDialog() {
- this.importShow = false;
- },
- /** 导出按钮操作 */
- handleExport() {
- const boxIds = this.ids || [];
- if (boxIds.length == 0) {
- this.$alert("请选择你要导出的盲票组!", "提示", { type: "warning" });
- } else {
- this.$confirm("是否确认导出所选盲票数据项?", "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- })
- .then(() => {
- this.exportLoading = true;
- return exportTicket({ ids: boxIds });
- })
- .then((response) => {
- this.download(response.msg);
- this.exportLoading = false;
- })
- .catch(() => {
- this.exportLoading = false;
- });
- }
- },
- },
- mounted() {},
- destroyed() {},
- };
- </script>
- <style lang="scss">
- .ticket-table {
- thead {
- .el-checkbox {
- display: none !important;
- }
- }
- }
- </style>
|