123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <template>
- <a-card size="small" :bordered="false" class="shelfSetList-wrap jg-page-wrap">
- <a-spin :spinning="spinning" tip="Loading...">
- <!-- 搜索条件 -->
- <div ref="tableSearch" class="table-page-search-wrapper">
- <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
- <a-row :gutter="15">
- <a-col :md="6" :sm="24">
- <a-form-item label="货架名称">
- <shelfSList v-model="queryParam.shelfSn" id="shelfSetList-shelfName"></shelfSList>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="关联客户">
- <custList ref="custList" id="shelfSetList-custList" @change="custChange" :isEnabled="true"></custList>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24">
- <a-form-item label="是否设置完成">
- <v-select
- v-model="queryParam.finishFlag"
- ref="finishFlag"
- id="shelfSetList-finishFlag"
- code="FLAG"
- placeholder="请选择"
- allowClear></v-select>
- </a-form-item>
- </a-col>
- <a-col :md="6" :sm="24" style="margin-bottom: 10px">
- <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shelfSetList-refresh">查询</a-button>
- <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="shelfSetList-reset">重置</a-button>
- </a-col>
- </a-row>
- </a-form>
- </div>
- <!-- 提示 -->
- <a-alert type="info" style="margin-bottom: 10px">
- <div slot="message">注意:只有当数字货架的“是否设置完成”为"是",修理厂才能正常下单。</div>
- </a-alert>
- <!-- 列表 -->
- <s-table
- class="sTable fixPagination"
- ref="table"
- :style="{ height: tableHeight+84.5+'px' }"
- size="small"
- :rowKey="(record) => record.id"
- :columns="columns"
- :data="loadData"
- :scroll="{ y: tableHeight }"
- :defaultLoadData="false"
- bordered>
- <!-- 货架名称 -->
- <template slot="shelfName" slot-scope="text, record">
- {{ record.shelfName }}
- <a-badge count="已注销" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#fff',background:'#999' }" v-if="record.state=='WRITE_OFF'"></a-badge>
- <a-badge count="已暂停" :number-style="{ zoom:'80%',marginLeft:'5px', color: '#fff',background:'#999' }" v-if="record.state=='SUSPEND'"></a-badge>
- </template>
- <!-- 货位数量 -->
- <template slot="shelfPlaceNum" slot-scope="text, record">
- <p style="margin: 0;">
- <span style="color: red;">
- {{ record.shelfPlaceBindNum||record.shelfPlaceBindNum==0 ? record.shelfPlaceBindNum:'' }}</span> /
- {{ record.shelfPlaceNum }}
- </p>
- </template>
- <!-- 是否设置完成 -->
- <template slot="finishFlag" slot-scope="text, record">
- <a-switch
- checkedChildren="是"
- unCheckedChildren="否"
- :disabled="record.state=='WRITE_OFF'||record.state=='SUSPEND'"
- v-if="record.finishFlag!=undefined"
- @change="changeStatus(record)"
- :checked="record.finishFlag == 1"
- :id="'shelfSetList-finishFlag-'+record.id"
- />
- <span v-else :style="{ color: record.finishFlag == 1 ? '#00aa00' : '#999' }">
- {{ record.finishFlag == 1 ? '是' : (record.finishFlag!=undefined?'否':'--') }}
- </span>
- </template>
- <!-- 启用禁用 -->
- <template slot="enableFlag" slot-scope="text, record">
- <a-switch
- checkedChildren="启用"
- unCheckedChildren="停用"
- :disabled="record.state=='WRITE_OFF'||record.state=='SUSPEND'"
- v-if="record.state!=undefined"
- @change="enableShelf(record)"
- :checked="record.state == 'ENABLE'"
- :id="'shelfSetList-state-'+record.id"
- />
- <span v-else :style="{ color: record.state == 'ENABLE' ? '#00aa00' : '#999' }">
- {{ record.state == 'ENABLE' ? '启用' : (record.state!=undefined&&record.state!='WRITE_OFF'&&record.state!='SUSPEND'?'停用':'--') }}
- </span>
- </template>
- <!-- 操作 -->
- <template slot="action" slot-scope="text, record">
- <div>
- <a-button id="shelfSetList-setView" size="small" type="link" class="button-primary" @click="handleSet(record)">{{ record.state!='WRITE_OFF'&&record.state!='SUSPEND'?'货架设置':'查看' }}</a-button>
- <a-button
- :id="'shelfSetList-cancel-'+record.id"
- size="small"
- type="link"
- class="button-primary"
- v-if="record.state!='WRITE_OFF'&&record.state!='SUSPEND'"
- @click="handleCancel(record)">注销</a-button>
- </div>
- </template>
- </s-table>
- </a-spin>
- <!-- 基础设置 -->
- <basic-info-modal :type="0" :openModal="openModal" :nowData="nowData" @ok="handleOkToSet" @close="openModal=false" />
- <a-modal
- centered
- class="common-modal"
- :footer="null"
- :maskClosable="false"
- v-model="showTip"
- title="注销"
- @cancel="showTip=false"
- :width="416">
- <div style="text-align:center;">
- <div style="font-size:16px;">是否注销该数字货架?</div>
- <div style="font-size:14px;">点击确定,该数字货架就不可做任何操作,用户不可登陆</div>
- <div style="font-size:12px;color:#999;margin-top:10px;">如需要迁移该数字货架的数据,可去货架设置中导出货架信息</div>
- </div>
- <div class="btn-box" style="display: flex;align-items: center;justify-content: center;margin-top:25px;">
- <a-button id="shelfSetList-handle-ok" type="primary" @click="handleCommonOk">确定</a-button>
- <a-button id="shelfSetList-handle-cancel" type="default" class="button-warning" @click="showTip=false">取消</a-button>
- </div>
- </a-modal>
- </a-card>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { STable, VSelect } from '@/components'
- import custList from '@/views/common/custList.vue' // 客户列表组件
- import shelfSList from '@/views/common/shelfList' // 货架列表组件
- import basicInfoModal from './basicInfoModal.vue' // 基本信息弹框
- import commonModal from '@/views/common/commonModal.vue' // 公共弹框
- import { shelfList, modifFinishFlag, shelfModifState } from '@/api/shelf' // 接口api
- export default {
- components: { STable, VSelect, custList, shelfSList, basicInfoModal, commonModal },
- mixins: [commonMixin],
- data () {
- return {
- spinning: false, // loading
- tableHeight: 0, // 表格高度
- disabled: false, // 查询、重置按钮是否可操作
- showTip: false, // 注销弹框
- queryParam: {
- shelfSn: undefined, // 货架sn
- customerSn: undefined, // 关联客户sn
- finishFlag: undefined, // 是否完成设置
- customerEntity: { // 关联客户名称
- customerName: undefined
- }
- },
- // 列定义
- columns: [
- { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
- { title: '货架名称', scopedSlots: { customRender: 'shelfName' }, width: '25%', align: 'left', ellipsis: true },
- { title: '关联客户', dataIndex: 'customerEntity.customerName', width: '25%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
- { title: '货位数量', scopedSlots: { customRender: 'shelfPlaceNum' }, width: '15%', align: 'center' },
- { title: '是否设置完成', scopedSlots: { customRender: 'finishFlag' }, width: '10%', align: 'center' },
- { title: '启用状态', scopedSlots: { customRender: 'enableFlag' }, width: '10%', align: 'center' },
- { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
- ],
- // 加载数据方法 必须为 Promise 对象
- loadData: parameter => {
- this.disabled = true
- this.spinning = true
- return shelfList(Object.assign(parameter, this.queryParam)).then(res => {
- let data
- if (res.status == 200) {
- data = res.data
- const no = (data.pageNo - 1) * data.pageSize
- for (var i = 0; i < data.list.length; i++) {
- data.list[i].no = no + i + 1
- }
- this.disabled = false
- }
- this.spinning = false
- return data
- })
- },
- openModal: false, // 新增编辑弹框
- nowData: null // 当前操作行数据
- }
- },
- methods: {
- // 设置/修改
- handleSet (row) {
- // 如果有关联客户跳转到设置页面
- if (row.customerSn) {
- this.handleOkToSet(row)
- } else {
- // 否则打开编辑弹框
- this.nowData = {
- shelfSn: row.shelfSn,
- shelfName: row.shelfName
- }
- this.openModal = true
- }
- },
- // 跳转到货架设置页面
- handleOkToSet (data) {
- this.$router.push({ path: `/numsGoodsShelves/shelfSet/set/${data.shelfSn}` })
- },
- // 选择关联客户
- custChange (obj, row) {
- if (row) {
- this.queryParam.customerSn = row && row.customerSn || undefined
- this.queryParam.customerEntity.customerName = undefined
- } else {
- this.queryParam.customerEntity.customerName = obj || undefined
- this.queryParam.customerSn = undefined
- }
- },
- // 是否设置完成更改
- changeStatus (record) {
- const params = {
- shelfSn: record.shelfSn,
- finishFlag: record.finishFlag == 1 ? '0' : '1'
- }
- this.spinning = true
- modifFinishFlag(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.table.refresh()
- this.spinning = false
- } else {
- this.spinning = false
- }
- })
- },
- // 启用禁用
- enableShelf (record) {
- const params = {
- shelfSn: record.shelfSn,
- state: record.state == 'ENABLE' ? 'DISABLED' : 'ENABLE'
- }
- const _this = this
- _this.$confirm({
- title: '提示',
- content: <div style="text-align:center;">是否{(record.state == 'ENABLE' ? '停用' : '启用') + record.shelfName}</div>,
- centered: true,
- closable: true,
- class: 'confirm-center',
- onOk () {
- _this.updateState(params)
- }
- })
- },
- // 打开注销弹框
- handleCancel (record) {
- this.nowData = {
- shelfSn: record.shelfSn,
- state: 'WRITE_OFF'
- }
- this.showTip = true
- },
- // 确定注销
- handleCommonOk () {
- this.updateState(this.nowData)
- },
- // 更改货架状态
- updateState (params) {
- this.spinning = true
- shelfModifState(params).then(res => {
- if (res.status == 200) {
- this.$message.success(res.message)
- this.$refs.table.refresh()
- this.spinning = false
- } else {
- this.spinning = false
- }
- this.showTip = false
- })
- },
- // 重置列表查询
- resetSearchForm () {
- this.queryParam.shelfSn = undefined
- this.queryParam.customerSn = undefined
- this.queryParam.customerEntity.customerName = undefined
- this.$refs.custList.resetForm()
- this.queryParam.finishFlag = undefined
- this.$refs.table.refresh(true)
- },
- // 计算表格高度
- setTableH () {
- const tableSearchH = this.$refs.tableSearch.offsetHeight
- this.tableHeight = window.innerHeight - tableSearchH - 235
- },
- // 初始化页面
- pageInit () {
- const _this = this
- this.$nextTick(() => { // 页面渲染完成后的回调
- _this.setTableH()
- })
- }
- },
- mounted () {
- if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
- this.pageInit()
- this.resetSearchForm()
- }
- },
- watch: {
- '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
- this.setTableH()
- }
- },
- activated () {
- // 如果是新页签打开,则重置当前页面
- if (this.$store.state.app.isNewTab) {
- this.pageInit()
- this.resetSearchForm()
- }
- // 仅刷新列表,不重置页面
- if (this.$store.state.app.updateList) {
- this.pageInit()
- this.$refs.table.refresh()
- }
- }
- }
- </script>
|