Browse Source

完善检定

408249787 2 năm trước cách đây
mục cha
commit
e7d34ad56c

+ 15 - 1
src/api/sb/info.js

@@ -16,7 +16,21 @@ export function getSbInfoPage (parameter) {
     }
   })
 }
-
+/**
+ * page func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getsbPositionNoPage (parameter) {
+  return axios({
+    url: '/sb/locations/page?' + stringify(parameter),
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
 /**
  * page func
  * parameter: { }

+ 24 - 5
src/views/sb/info/modules/BaseFormMeasure.vue

@@ -23,6 +23,7 @@
               <th width="150px">是否是子设备</th>
               <th width="350px">选择父设备</th>
               <th width="150px">设备位置</th>
+              <th width="150px">设备位号</th>
               <th width="150px">检定周期</th>
               <th width="150px">检定单号</th>
               <th width="150px">检定日期</th>
@@ -46,7 +47,6 @@
                        style="width: 50%"
                        v-model="item.parentSbName"/>
                      <a-button type="primary" @click="handleSbSelect(i)">选择</a-button>
-                     <a-button type="default" @click="clearParent">清空</a-button>
                    </div>
                 <div v-else>无</div></td>
               <td><a-tree-select
@@ -59,6 +59,16 @@
                 placeholder="请选择"
               >
               </a-tree-select></td>
+              <td>
+                <a-input v-if="item.isChild === 0" style="width: 150px" v-model="item.sbNoId" />
+                <div v-else style="width:300px">
+                  <a-input
+                    disabled
+                    style="width: 50%"
+                    v-model="item.sbNoId"/>
+                  <a-button type="primary" @click="handleSbNoSelect(i)">选择</a-button>
+                </div>
+              </td>
               <td><a-input v-model="item.checkPeriod" :formatter="BaseTool.Amount.formatter" :parser="BaseTool.Amount.parser"> <span slot="suffix" >月</span> </a-input></td>
               <td><a-input style="width: 150px" v-model="item.no" /></td>
               <td><a-date-picker
@@ -110,6 +120,7 @@
       </div>
     </div>
     <sb-info-select-modal ref="sbInfoSelectModal" @selected="handleSbSelectd"/>
+    <sb-position-no-modal ref="sbPositionNoModal" @selected="handleSbNoSelectd"/>
 
   </a-card>
 </template>
@@ -117,6 +128,7 @@
 <script>
 import { getSbPositionTree } from '@/api/sb/position'
 import SbInfoSelectModal from '@/views/sb/info/modules/SbInfoSelectModal'
+import SbPositionNoModal from '@/views/sb/info/modules/SbPositionNoModal'
 import { importMeasure } from '@/api/sb/info'
 
 import { uploadUrl } from '@/api/upms/file'
@@ -127,7 +139,8 @@ import { status } from 'nprogress'
 export default {
   name: 'BaseFillGatherTask',
   components: {
-    SbInfoSelectModal
+    SbInfoSelectModal,
+    SbPositionNoModal
 
   },
   data () {
@@ -189,6 +202,7 @@ export default {
           positionId: item.positionId,
           no: '',
           lastDate: '',
+          sbNoId: item.positionNo,
           requirement: '',
           remark: '',
           name: this.username,
@@ -202,19 +216,24 @@ export default {
       getSbPositionTree().then(res => {
         this.treeData = res.data
       })
-    },
-    clearParent () {
-
     },
     handleSbSelect (i) {
       this.sbParentOPt = i
       this.$refs.sbInfoSelectModal.base({}, { isChild: this.DictCache.VALUE.SB_IS_CHILD.IS_PARENT })
     },
+    handleSbNoSelect (i) {
+      this.sbParentOPt = i
+      this.$refs.sbPositionNoModal.base()
+    },
     handleSbSelectd (keys, rows) {
       console.log(keys, rows)
       this.ListForm[ this.sbParentOPt ].sbParentId = keys[0]
       this.ListForm[ this.sbParentOPt ].parentSbName = rows[0].name
     },
+    handleSbNoSelectd (keys, rows) {
+      console.log(keys, rows)
+      this.ListForm[ this.sbParentOPt ].sbNoId = rows[0].no
+    },
     uploadFile (val, i) {
       this.uploadFiledVisible = true
       this.fileId = i

+ 226 - 0
src/views/sb/info/modules/SbPositionNoModal.vue

@@ -0,0 +1,226 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="1300"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+  >
+    <a-card :bordered="false">
+      <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="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 { getsbPositionNoPage } from '@/api/sb/info'
+
+export default {
+  name: 'SbInfoSelectModal',
+  components: {
+    STable,
+    Ellipsis
+  },
+  props: {
+    type: {
+      type: String,
+      default: 'radio'
+    },
+    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: {},
+      // 表头
+      columns: [
+        {
+          title: '部位名称',
+          checked: true,
+          dataIndex: 'name'
+        },
+        {
+          title: '部位编号',
+          dataIndex: 'no',
+          checked: true
+        },
+
+        {
+          title: '部位类型',
+          dataIndex: 'type',
+          checked: true,
+          width: 200,
+          customRender: (text, record, index) => {
+            return record.typeName
+          }
+        }
+      ],
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        parameter = {
+          ...parameter,
+          ...this.queryParam
+        }
+        return getsbPositionNoPage(Object.assign(parameter))
+          .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)
+  },
+  methods: {
+    tableOption () {
+      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.$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.extraQueryParam = 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)
+    }
+  }
+}
+</script>