| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 | <template>  <a-row :gutter="24">    <a-col :md="24">      <a-card :bordered="false">        <!-- 查询区域 -->        <filter-form          @search="onSearch"          @reset="onReset"          :queryParam="queryParam"          :spinnerList="spinnerList"          :deoptData="deoptData"        ></filter-form>        <div style="margin-bottom: 6px">          <a-button type="primary" icon="plus" @click="addTask('add')">新增盘点任务</a-button>          <a-popconfirm            :disabled="!selectedRowKeys.length"            style="margin: 0 6px"            title="确定取消选中的盘点任务吗?"            @confirm="() => cancelTask()"          >            <a-button :disabled="!selectedRowKeys.length">取消盘点</a-button>          </a-popconfirm>          <a-popconfirm            :disabled="!selectedRowKeys.length"            title="确定删除选中的盘点任务吗?"            @confirm="() => handleDelete()"          >            <a-button :disabled="!selectedRowKeys.length">批量删除</a-button>          </a-popconfirm>          <!-- <a-button style="margin-left: 6px">导出任务</a-button> -->        </div>        <a-table          ref="table"          size="middle"          bordered          rowKey="id"          :columns="columns"          :dataSource="dataSource"          :pagination="ipagination"          :scroll="scroll"          :loading="loading"          :rowSelection="{            selectedRowKeys: selectedRowKeys,            onChange: onSelectChange,          }"          @change="handleTableChange"        >          <template slot="taskType" slot-scope="value">            {{ value === 1 ? '全盘' : '抽盘' }}          </template>          <template slot="taskStatus" slot-scope="value">            {{ formateTaskStatus(value) }}          </template>          <span slot="action" slot-scope="text, record">            <a @click="addTask('detail', record)">查看</a>            <a-divider type="vertical" />            <a :disabled="record.taskStatus !== 1" @click="addTask('edit', record)">编辑</a>            <a-divider type="vertical" />            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">              <a :disabled="record.taskStatus !== 1 && record.taskStatus !== 4">删除</a>            </a-popconfirm>          </span>        </a-table>      </a-card>    </a-col>    <stock-modal      :spinnerList="spinnerList"      :deoptData="deoptData"      :stockVisible.sync="stockVisible"      :title="title"      :rules="rules"      :taskId="taskId"      :openType="openType"      ref="stockF"    ></stock-modal>  </a-row></template><script>// import { JeecgListMixin } from '@/mixins/JeecgListMixin'import FilterForm from './components/FilterForm.vue'import table from './utils/table'import StockModal from './components/stockModal.vue'import { getAction, postAction } from '@/api/manage'import { newTableMixin } from '@/mixins/newTableMixin'export default {  components: { FilterForm, StockModal },  mixins: [newTableMixin],  data() {    return {      description: '盘点任务列表',      // 表头      scroll: { x: 1500 },      // 权限按钮集合      btnEnableList: [1, 1, 1],      queryParam: {        taskStatus: undefined,        number: '',        depotId: undefined,        createBy: undefined,      },      // stockTable: {      //   loading: false,      //   dataSource: [],      //   columns: table.taskColumns,      // },      columns: table.taskColumns,      dataSource: [],      loading: false,      rules: {        taskType: { rules: [{ required: true, message: '请选择盘点类型' }] },        depotId: { rules: [{ required: true, message: '请选择盘点仓库' }] },        taskName: { rules: [{ required: true, message: '请输入盘点任务名称' }] },      },      // rules: {      //   number: { rules: [{ required: true, message: '请输入盘点编号' }] },      // },      url: {        list: '/stocktaking/list',        add: '/stocktaking/add',        detailList: '/stocktaking/detail',        spinnerList: '/stocktaking/creatorSpinnerList',        depotList: '/depot/findDepotByCurrentUser',        detailByItemList: '/stocktaking/detailByItemList',        delete: '/stocktaking/taskDelete/',        cancel: '/stocktaking/taskCancel/',      },      stockVisible: false,      title: '',      spinnerList: [],      deoptData: [],      taskId: '',      openType: 'add',    }  },  watch: {    stockVisible(val) {      if (!val) {        this.getList()      }    },  },  computed: {    isDel() {      return this.selectionRows.filter((item) => item.taskStatus !== 1 && item.taskStatus !== 4).length > 0        ? true        : false    },    isStock() {      return this.selectionRows.filter((item) => item.taskStatus !== 1 && item.taskStatus !== 2).length > 0        ? true        : false    },  },  created() {    this.getList()    this.getSpinnerList(), this.getDepotList()  },  methods: {    addTask(type, data) {      this.taskId = ''      this.openType = type      this.title = type === 'add' ? '新增盘点任务' : type === 'edit' ? '编辑盘点任务' : '查看盘点任务'      if (type !== 'add') {        this.getDetailList(data.id)      }      this.stockVisible = true    },    getList(type) {      if (type === 'search') this.ipagination.current = 1 // 重新加载数据时,重置当前页为第一页      if (type === 'reset') {        for (let i in this.queryParam) {          this.$set(this.queryParam, i, null)        }      }      const url = this.url.list + '?currentPage=' + this.ipagination.current + '&pageSize=' + this.ipagination.pageSize      this.loading = true      const params = { ...this.queryParam }      postAction(url, params).then((res) => {        this.dataSource = res.data.rows        this.ipagination.total = Number(res.data.total)        this.loading = false      })    },    getDetailList(id) {      this.taskId = id    },    getSpinnerList() {      getAction(this.url.spinnerList).then((res) => {        this.spinnerList = res.data || []      })    },    getDepotList() {      getAction(this.url.depotList).then((res) => {        this.deoptData = res.data.map((item) => {          return {            label: item.depotName,            value: item.id,          }        })      })    },    handleDelete(id) {      if (this.isDel) return this.$message.error('只能删除未开始或已取消的盘点任务,请重新选择!')      const ids = id || this.selectedRowKeys      const url = this.url.delete + ids      getAction(url)        .then((res) => {          this.$message.success('删除成功')          this.getList()        })        .catch((err) => {          this.$message.error('删除失败')        })    },    cancelTask() {      if (this.isStock) return this.$message.error('只能取消未开始或进行中的盘点任务,请重新选择!')      const ids = this.selectedRowKeys      const url = this.url.cancel + ids      getAction(url)        .then((res) => {          this.$message.success('取消成功')          this.getList()        })        .catch((err) => {          this.$message.error('取消失败')        })    },  },}</script><style></style>
 |