whj 11 місяців тому
батько
коміт
cba65d8112

+ 4 - 8
src/views/sb/info/SbInfoC.vue

@@ -186,8 +186,8 @@
                 检定导入
               </a-button>
               <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handlePrintBatch()">批量打印</a-button>
-              <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handleBackBatch(13)">批量退库</a-button>
-              <a-button style="margin-left: 8px" type="primary" icon="printer" @click="handleBackBatch(4)">批量报废</a-button>
+              <a-button style="margin-left: 8px" type="primary" @click="handleBackBatch(13)">批量退库</a-button>
+              <a-button style="margin-left: 8px" type="primary" @click="handleBackBatch(4)">批量报废</a-button>
               <!-- <a-button style="margin-left: 8px" type="primary" icon="reload" @click="handleMeasureBatch()">批量检定</a-button> -->
               <a-button style="margin-left: 8px" v-if="$auth('sb-infos-generate-code-all')" :loading="confirmLoading" type="primary" @click="batchGenerate()">重新生成二维码</a-button>
               <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('sb-infos-del')">
@@ -812,6 +812,7 @@ export default {
         parameter = {
           ...parameter,
           ...this.queryParam,
+
           dataScope: {
             sortBy: 'asc',
             sortName: 'position_no'
@@ -1002,13 +1003,8 @@ export default {
       })
     },
     handleBackBatch (status) {
-      const length = this.selectedRowKeys.length
-      if (length === 0) {
-        this.$message.info('请选择设备')
-        return
-      }
       const modal = this.$refs.backForm
-      modal.base(this.selectedRowKeys, status)
+      modal.base(status)
     },
     handleStart (record) {
       const modal = this.$refs.baseModalStatusLog

+ 79 - 7
src/views/sb/info/modules/BackForm.vue

@@ -1,11 +1,23 @@
 <template>
   <a-modal
     :title="modalTitle"
-    :width="800"
+    :width="1300"
     :visible="visible"
     :confirmLoading="confirmLoading"
     @cancel="handleCancel"
   >
+    <a-button icon="plus" type="primary" @click="$refs.sbSelect.base()">选择设备</a-button>
+    <a-table
+      bordered
+      :data-source="dataList"
+      :columns="columns"
+      :scroll="{x: 1300, y: BaseTool.Constant.scrollY}"
+    >
+      <span slot="status" slot-scope="text">
+        <badge :status="DictCache.COLOR.SB_INFO_STATUS[text]" :text="statusMap[text]" />
+      </span>
+    </a-table>
+    <br>
     <a-form :form="form">
       <row-list :col="1">
         <row-item>
@@ -24,14 +36,18 @@
     <template slot="footer">
       <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
     </template>
+    <SbInfoSelectModal ref="sbSelect" @selected="handleSelected" />
   </a-modal>
 </template>
 
 <script>
 import { batchBack } from '@/api/repair/application-form'
-
+import SbInfoSelectModal from './SbInfoSelectModal2.vue'
 export default {
-  name: 'DispatchBaseForm',
+  name: 'BackForm',
+  components: {
+    SbInfoSelectModal
+  },
   data () {
     return {
       confirmLoading: false,
@@ -40,21 +56,70 @@ export default {
       visible: false,
       // 下拉框map
       sbIds: [],
-      status: 0
+      dataList: [],
+      columns: [
+        {
+          title: '状态',
+          checked: true,
+          dataIndex: 'status',
+          align: 'center',
+          width: 100,
+          scopedSlots: { customRender: 'status' }
+        },
+        {
+          title: '车间',
+          checked: true,
+          width: 150,
+          dataIndex: 'positionName'
+        },
+        {
+          title: '父位号',
+          dataIndex: 'no',
+          width: 100,
+          checked: true
+        },
+        {
+          title: '设备名称',
+          checked: true,
+          dataIndex: 'name',
+          width: 150
+        },
+        {
+          title: '规格、型号',
+          dataIndex: 'model',
+          width: 150,
+          checked: true
+        },
+        {
+          title: '出厂编号',
+          dataIndex: 'zzh',
+          width: 100,
+          checked: true
+        },
+        {
+          title: '管理编号',
+          dataIndex: 'positionNo',
+          width: 120,
+          checked: true
+        }
+      ],
+      status: 0,
+      statusMap: {}
     }
   },
   props: {
   },
   created () {
     // 下拉框map
+    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
   },
   methods: {
-    base (sbIds, status) {
+    base (status) {
       this.visible = true
       // 如果是空标识添加
       this.modalTitle = status === 4 ? '报废' : '退库'
-      this.sbIds = sbIds
       this.status = status
+      this.dataList = []
     },
     save () {
       const { form: { validateFieldsAndScroll } } = this
@@ -64,7 +129,7 @@ export default {
           this.confirmLoading = false
           return
         }
-        values.sbIds = this.sbIds
+        values.sbIds = this.dataList.map((value) => value.id)
         values.status = this.status
         batchBack(values).then(res => {
           this.confirmLoading = false
@@ -72,6 +137,13 @@ export default {
         })
       })
     },
+    handleSelected (keys, rows) {
+      rows.forEach((item) => {
+        if (!this.dataList.map((company) => company.id).includes(item.id)) {
+          this.dataList.push(item)
+        }
+      })
+    },
     handleCancel (values) {
       this.visible = false
       this.confirmLoading = false

+ 345 - 0
src/views/sb/info/modules/SbInfoSelectModal2.vue

@@ -0,0 +1,345 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="1300"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+  >
+    <a-card :bordered="false">
+      <div class="table-page-search-wrapper">
+        <a-form layout="inline">
+          <a-row :gutter="48">
+            <a-col :md="8" :sm="24">
+              <a-form-item label="关键字">
+                <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/编码"/>
+              </a-form-item>
+            </a-col>
+            <!--            <a-col :md="8" :sm="24">
+              <a-form-item label="上层设备类型">
+                <a-tree-select
+                  style="width: 100%"
+                  :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
+                  :treeData="treeData"
+                  :treeNodeFilterProp="'title'"
+                  :showSearch="true"
+                  v-model="queryParam.parentId"
+                  placeholder="请选择"
+                >
+                </a-tree-select>
+              </a-form-item>
+            </a-col>-->
+            <a-col :md="6" :sm="24">
+              <a-form-item label="车间位置">
+                <a-select v-model="queryParam.positionId" placeholder="请选择">
+                  <a-select-option
+                    v-for="({id,name}) in sbPositionData"
+                    :key="id"
+                    :label="name"
+                    :value="id">{{ name }}
+                  </a-select-option>
+                </a-select>
+              </a-form-item>
+            </a-col>
+            <a-col :md="8 || 24" :sm="24">
+              <span class="table-page-search-submitButtons">
+                <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
+                <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
+              </span>
+            </a-col>
+          </a-row>
+        </a-form>
+      </div>
+
+      <div class="table-operator" style="margin-bottom: 8px;">
+      </div>
+
+      <s-table
+        ref="table"
+        size="default"
+        rowKey="id"
+        :columns="columns"
+        :data="loadData"
+        :alert="options.alert"
+        :customRow="options.customRow"
+        :rowSelection="options.rowSelection"
+        :scroll="{ x: 1300, y: BaseTool.Constant.scrollY }"
+        showPagination="auto"
+      >
+        <span slot="action" slot-scope="record">
+          <template>
+
+          </template>
+        </span>
+        <span slot="status" slot-scope="text">
+          <badge :status="DictCache.COLOR.SB_INFO_STATUS[text]" :text="statusMap[text]" />
+        </span>
+      </s-table>
+    </a-card>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">取消</a-button>
+      <a-button :loading="confirmLoading" type="primary" @click="handleSelect()">选择</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import { STable, Ellipsis } from '@/components'
+import { getSbInfoPage2, fetchSbInfo, getSbInfoTree } from '@/api/sb/info'
+import { querySbPosition } from '@/api/sb/position'
+import { fetchSbTypeTree } from '@/api/sb/type'
+
+export default {
+  name: 'SbInfoSelectModal',
+  components: {
+    STable,
+    Ellipsis
+  },
+  props: {
+    type: {
+      type: String,
+      default: 'checkbox'
+    },
+    selectedRowKey: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    selectedRow: {
+      type: Array,
+      default: () => {
+        return []
+      }
+    }
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      mdl: {},
+      modalTitle: null,
+      visible: false,
+      // 查询参数
+      queryParam: {
+      },
+      extraQueryParam: {
+      },
+      depreciationTypeMap: {},
+      levelMap: {},
+      statusMap: {},
+      unitMap: {},
+      useTypeMap: {},
+      sourceTypeMap: {},
+      treeData: [],
+      sbPositionData: [],
+      typeList: [],
+      // 表头
+      columns: [
+        {
+          title: '设备名称',
+          checked: true,
+          dataIndex: 'name'
+        },
+        {
+          title: '设备编号',
+          dataIndex: 'no',
+          checked: true
+        },
+        {
+          title: '设备位号',
+          checked: true,
+          dataIndex: 'positionNo'
+        },
+        {
+          title: '型号',
+          checked: true,
+          dataIndex: 'model'
+        },
+        {
+          title: '设备类型',
+          dataIndex: 'type',
+          checked: true,
+          width: 200,
+          customRender: (text, record, index) => {
+            return record.typeName
+          }
+        },
+        {
+          title: '设备等级',
+          dataIndex: 'level',
+          checked: true,
+          width: 200,
+          customRender: (text, record, index) => {
+            return this.BaseTool.Object.getField(this.levelMap, text)
+          }
+        },
+        {
+          title: '状态',
+          dataIndex: 'status',
+          checked: true,
+          width: 200,
+          scopedSlots: { customRender: 'status' }
+        },
+        {
+          title: '备注',
+          dataIndex: 'remark',
+          width: 200
+        },
+        {
+          title: '操作',
+          key: 'action',
+          width: '200px',
+          align: 'center',
+          fixed: 'right',
+          scopedSlots: { width: 200, customRender: 'action' }
+        }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        parameter = {
+          ...parameter,
+          ...this.queryParam,
+          ...this.extraQueryParam,
+          filter: -1,
+          useType: 4,
+          dataScope: {
+            sortBy: 'asc',
+            sortName: 'position_no'
+          }
+        }
+        return getSbInfoPage2(Object.assign(parameter, this.queryParam))
+          .then(res => {
+            return res.data
+          })
+      },
+      selectedRowKeys: [],
+      selectedRows: [],
+
+      options: {
+        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+        rowSelection: {
+          selectedRowKeys: this.selectedRowKeys,
+          onChange: this.onSelectChange
+        }
+      },
+      optionAlertShow: true,
+      isCreated: false
+    }
+  },
+  created () {
+    this.tableOption()
+    this.depreciationTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_DEPRECIATIONTYPE)
+    this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_LEVEL)
+    this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
+    this.unitMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBINFO_UNIT)
+    this.sourceTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SBTYPE_SOURCETYPE)
+    this.useTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_UES_TYPE)
+    querySbPosition().then(res => {
+      this.sbPositionData = res.data
+    })
+    fetchSbTypeTree().then(res => {
+      this.treeData = res.data
+    })
+  },
+  methods: {
+    tableOption () {
+      // this.setTree()
+      if (!this.optionAlertShow) {
+        this.options = {
+          alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
+          rowSelection: {
+            selectedRowKeys: this.selectedRowKeys,
+            onChange: this.onSelectChange,
+            type: this.type,
+            getCheckboxProps: record => ({
+              props: {
+                disabled: false,
+                name: record.id
+              }
+            })
+          },
+          customRow: (record) => {
+            return {
+              on: { // 事件
+                click: (event) => { // 点击行
+                  // 选择对象
+                  this.mySelect([record.id], [record])
+                },
+                dblclick: (event) => {
+                  this.mySelect([record.id], [record])
+                  this.handleSelect()
+                }
+              }
+            }
+          }
+        }
+        this.optionAlertShow = true
+      } else {
+        this.options = {
+          alert: false,
+          rowSelection: null
+        }
+        this.optionAlertShow = false
+      }
+    },
+    handleOk () {
+      // this.setTree()
+      this.$refs.table.refresh()
+    },
+    onSelectChange (selectedRowKeys, selectedRows) {
+      this.selectedRowKeys = selectedRowKeys
+      this.selectedRows = selectedRows
+    },
+    resetSearchForm () {
+      this.queryParam = {
+      }
+      this.$refs.table.refresh(true)
+    },
+    /**
+     * 设置设备类型树
+     */
+    base (record, queryParam = {}) {
+      this.visible = true
+      this.modalTitle = '选择设备'
+      this.queryParam = queryParam
+      if (this.isCreated) {
+        console.log(this.$refs.table)
+        this.$refs.table.clearSelected()
+        this.options.rowSelection.type = this.type
+        this.handleOk()
+      } else {
+        this.tableOption()
+        this.isCreated = true
+      }
+      // this.mySelect(this.selectedRowKeys, this.selectedRows)
+    },
+    handleCancel () {
+      this.visible = false
+      this.confirmLoading = false
+    },
+    handleSelect () {
+      if (this.selectedRowKeys.length === 0) {
+        this.$message.warn('请至少选择一项信息')
+      } else {
+        this.confirmLoading = true
+        this.$emit('selected', this.selectedRowKeys, this.selectedRows)
+        this.confirmLoading = false
+        this.visible = false
+      }
+    },
+    mySelect (selectedRowKeys, selectedRows) {
+      this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
+      this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
+    },
+    handleChange (value, label, extra) {
+      const data = this.treeData.find(item => item.id === value)
+      if (data && data.children && data.children.length > 0) {
+        this.typeList = data.children.map(item => item.id)
+      } else {
+        this.typeList = [value]
+      }
+    }
+  }
+}
+</script>