408249787 il y a 2 ans
Parent
commit
1fd1f58e9e

+ 34 - 0
src/api/fill/gather.js

@@ -125,3 +125,37 @@ export function exportFillGather (parameter) {
     responseType: 'blob'
   })
 }
+
+/**
+ * query list func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function getQueryUser (parameter) {
+  return axios({
+    url: '/upms/users/query/user/' + parameter,
+    method: 'get',
+    headers: {
+      'Content-Type': 'application/json;charset=UTF-8'
+    }
+  })
+}
+
+/**
+ * add func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function addFillTasks (parameter) {
+  return axios({
+    url: '/fill/tasks',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}

+ 5 - 0
src/utils/dict.js

@@ -986,6 +986,11 @@ DictCache.VALUE = {
     'NORMAL': 1, // 正常
     'STOP': 2 // 停机
 
+  },
+  QUERY_ROLE_TYPE: {
+    'IPQC': 1, // 巡检人
+    'DIRCTOR': 2 // 巡检主管
+
   },
   SYS_DEPT_CODE: {
     DEFAULT: 'DEFAULT',

+ 9 - 3
src/views/fill/gather/FillGather.vue

@@ -59,13 +59,13 @@
           <operation-button
             v-if="$auth('fill-gathers-edit')"
             @click="handleConfigEdit(record)"
-          >配置列表</operation-button>
+          >生成任务</operation-button>
         </template>
       </span>
     </s-table>
     <base-form ref="baseModal" @ok="handleOk"/>
     <detail ref="detailModal"/>
-    <fill-gather-info-select-modal ref="fillGatherInfoSelectModal" />
+    <create-task-form ref="createTaskModal" />
   </a-card>
 </template>
 
@@ -73,6 +73,7 @@
 import { STable, Ellipsis } from '@/components'
 import BaseForm from './modules/BaseForm'
 import Detail from './modules/Detail'
+import CreateTaskForm from './modules/CreateTaskForm'
 import FillGatherInfoSelectModal from '@/views/fill/gather-info/modules/FillGatherInfoSelectModal'
 import { getFillGatherPage, deleteFillGathers, fetchFillGather, exportFillGather } from '@/api/fill/gather'
 
@@ -83,6 +84,7 @@ export default {
     Ellipsis,
     BaseForm,
     Detail,
+    CreateTaskForm,
     FillGatherInfoSelectModal
   },
   data () {
@@ -218,7 +220,10 @@ export default {
       })
     },
     handleConfigEdit (record) {
-      this.$refs.fillGatherInfoSelectModal.base({}, { gatherId: record.id })
+      fetchFillGather({ id: record.id }).then(res => {
+        const modal = this.$refs.createTaskModal
+        modal.base(res.data)
+      })
     },
     handleEdit (record) {
       fetchFillGather({ id: record.id }).then(res => {
@@ -227,6 +232,7 @@ export default {
       })
     },
     handleView (record) {
+      console.log(this.loadData())
       fetchFillGather({ id: record.id }).then(res => {
         const modal = this.$refs.detailModal
         modal.base(res.data)

+ 5 - 2
src/views/fill/gather/modules/BaseForm.vue

@@ -111,8 +111,8 @@
     </a-form>
     <template slot="footer">
       <a-button v-show="content == 1" :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
-      <a-button v-show="content == 0" :loading="confirmLoading" type="primary" @click="content++">下一步</a-button>
-      <a-button v-show="content == 1" :loading="confirmLoading" type="primary" @click="content--">上一步</a-button>
+      <a-button v-show="content == 0" type="primary" @click="content++">下一步</a-button>
+      <a-button v-show="content == 1" type="primary" @click="content--">上一步</a-button>
     </template>
   </a-modal>
 </template>
@@ -176,6 +176,9 @@ export default {
       this.confirmLoading = true
       validateFieldsAndScroll((errors, values) => {
         if (errors) {
+          Object.values(errors).map(item => {
+            this.$message.error(item.errors[0].message)
+          })
           this.confirmLoading = false
           return
         }

+ 216 - 0
src/views/fill/gather/modules/CreateTaskForm.vue

@@ -0,0 +1,216 @@
+<template>
+  <a-modal
+    title="生成任务"
+    :width="800"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @cancel="handleCancel"
+  >
+    <a-form :form="form">
+      <a-row type="flex">
+        <a-col :sm="20" >
+          <a-form-item
+            label="巡检任务名称"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input v-decorator="['name', {rules: [{required: true, message: '巡检任务名称不能为空'}]}]" />
+          </a-form-item>
+        </a-col>
+
+        <a-col :sm="20" >
+          <a-form-item
+            label="巡检人"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-select v-decorator="['checker', {rules: [{required: true, message: '巡检人不能为空'}]}]">
+              <a-select-option
+                v-for="item in ipqcMap"
+                :key="item.userId"
+                :label="item.realName"
+                :value="item.userId">
+                {{ item.realName }}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="巡检主管"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-select v-decorator="['checkLeader', {rules: [{required: true, message: '巡检主管不能为空'}]}]">
+              <a-select-option
+                v-for="item in directorMap"
+                :key="item.userId"
+                :label="item.realName"
+                :value="item.userId">
+                {{ item.realName }}
+              </a-select-option>
+            </a-select>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="巡检设备"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            {{ sbIds.length }}台
+            <a-button style="width: 30% ;float: right;" type="primary" @click="handleSbSelect">选择</a-button>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="巡检内容项"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            {{ infoNum }}个
+            <a-button style="width: 30% ;float: right;" type="primary" @click="handleInfoSelect">查看</a-button>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="巡检频次"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input-number
+              :min="0"
+              :formatter="value => `${value}天`"
+              :parser="value => value.replace('天', '')"
+              v-decorator="['period', {rules: [{required: true, message: '巡检频次不能为空'}]}]"/>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="要求时间"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input-number
+              :min="0"
+              :formatter="value => `${value}小时`"
+              :parser="value => value.replace('小时', '')"
+              v-decorator="['requireHour', {rules: [{required: true, message: '要求时间不能为空'}]}]"/>
+          </a-form-item>
+        </a-col>
+        <a-col :sm="20" >
+          <a-form-item
+            label="超时预警时间"
+            :labelCol="BaseTool.Constant.labelCol"
+            :wrapperCol="BaseTool.Constant.wrapperCol"
+          >
+            <a-input-number
+              :min="0"
+              :formatter="value => `${value}小时`"
+              :parser="value => value.replace('小时', '')"
+              v-decorator="['warningHour', {rules: [{required: true, message: '超时预警时间不能为空'}]}]"/>
+          </a-form-item>
+        </a-col>
+      </a-row>
+    </a-form>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
+    </template>
+    <sb-info-select-modal ref="sbInfoSelectModal" type="checkbox" @selected="handleSbSelectd"/>
+    <info-select-modal ref="infoSelectModal"/>
+
+  </a-modal>
+</template>
+
+<script>
+import { getQueryUser, addFillTasks } from '@/api/fill/gather'
+import SbInfoSelectModal from './SbInfoSelectModal'
+import InfoSelectModal from './InfoSelectModal'
+
+export default {
+  name: 'BaseFillGather',
+  data () {
+    return {
+      form: this.$form.createForm(this),
+      visible: false,
+      ipqcMap: [],
+      model: {},
+      sbIds: [],
+      directorMap: [],
+      infoNum: 0,
+      confirmLoading: false
+    }
+  },
+  components: {
+    SbInfoSelectModal,
+    InfoSelectModal
+  },
+  props: {},
+  created () {
+    this.getUser()
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+      this.model = record
+      this.infoNum = record.infos.length
+      const { form: { setFieldsValue } } = this
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign({
+          period: record.period,
+          warningHour: 2
+        }))
+      })
+    },
+    // 获取巡检人与巡检主管信息
+    getUser () {
+      getQueryUser(this.DictCache.VALUE.QUERY_ROLE_TYPE.IPQC).then(res => {
+        this.ipqcMap = res.data
+      })
+      getQueryUser(this.DictCache.VALUE.QUERY_ROLE_TYPE.DIRCTOR).then(res => {
+        this.directorMap = res.data
+      })
+    },
+    handleSbSelect () {
+      this.$refs.sbInfoSelectModal.base({}, {})
+    },
+    handleInfoSelect () {
+      this.$refs.infoSelectModal.base(this.model)
+    },
+    handleSbSelectd (keys, rows) {
+      this.sbIds = keys
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      // this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          Object.values(errors).map(item => {
+            this.$message.error(item.errors[0].message)
+          })
+          this.confirmLoading = false
+        } else if (this.sbIds.length === 0) {
+          console.log(values)
+          this.$message.error('巡检设备不能为空!')
+          return
+        }
+        values.sbIds = this.sbIds
+        console.log(values)
+        addFillTasks(values).then(res => {
+          this.$message.success('创建成功!')
+          this.handleCancel()
+        })
+      })
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.form.resetFields()
+      this.$emit('ok', values)
+    }
+
+  }
+}
+</script>
+<style lang="less" scoped>
+
+</style>

+ 87 - 0
src/views/fill/gather/modules/InfoSelectModal.vue

@@ -0,0 +1,87 @@
+<template>
+  <a-modal
+    title="巡检任务项"
+    :width="1000"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    class="ant-modal2"
+    @cancel="handleCancel"
+  >
+    <a-card :bordered="false">
+      <a-table
+        ref="table"
+        size="default"
+        rowKey="id"
+        bordered
+        :columns="columns"
+        :data-source="loadData"
+        :pagination="false"
+      >
+      </a-table>
+    </a-card>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="handleCancel()">返回</a-button>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+import { STable } from '@/components'
+export default {
+  name: 'FillInfoList',
+  components: {
+    STable
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      columns: [
+        {
+          title: '巡检项名称',
+          dataIndex: 'name'
+        },
+        /* {
+            title: '字段名称',
+            dataIndex: 'fieldKey'
+          }, */
+        {
+          title: '类型',
+          dataIndex: 'type',
+          customRender: (text, record, index) => {
+            return this.BaseTool.Table.getMapText(this.typeMap, text)
+          }
+        },
+        {
+          title: '备注',
+          dataIndex: 'remark'
+        },
+        {
+          title: '创建人名称',
+          dataIndex: 'createdUserName'
+        },
+        {
+          title: '创建日期',
+          dataIndex: 'createdTime'
+        }
+      ],
+      // 下拉框map
+      typeMap: {},
+      loadData: [],
+      visible: false
+    }
+  },
+  created () {
+    this.typeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.FILL_INFO_TYPE)
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+      this.loadData = record.infos
+    },
+    handleCancel () {
+      this.visible = false
+      this.$emit('ok')
+    }
+  }
+}
+</script>

+ 296 - 0
src/views/fill/gather/modules/SbInfoSelectModal.vue

@@ -0,0 +1,296 @@
+<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 || 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="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 { getSbInfoPage, getSbInfoTree } 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: {},
+      treeData: [],
+      // 表头
+      columns: [
+        {
+          title: '设备名称',
+          checked: true,
+          dataIndex: 'name'
+        },
+        {
+          title: '设备编号',
+          dataIndex: 'no',
+          checked: true
+        },
+        {
+          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,
+          dataScope: {
+            sortBy: 'asc',
+            sortName: 'no'
+          }
+        }
+        return getSbInfoPage(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)
+  },
+  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 = Array.from(new Set([...selectedRowKeys, ...this.selectedRowKeys]))
+      this.selectedRows = Array.from(new Set([...selectedRows, ...this.selectedRows]))
+    },
+    resetSearchForm () {
+      this.queryParam = {
+      }
+      this.$refs.table.refresh(true)
+    },
+    /**
+     * 设置设备类型树
+     */
+    setTree (record = {}) {
+      getSbInfoTree({ id: record.id }).then(res => {
+        this.treeData = res.data
+      })
+    },
+    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
+        this.selectedRowKeys = []
+        this.selectedRows = []
+      }
+    },
+    mySelect (selectedRowKeys, selectedRows) {
+      this.$refs.table.updateSelect([...selectedRowKeys, ...this.selectedRowKeys], [...selectedRows, ...this.selectedRows])
+      this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
+    }
+  }
+}
+</script>

+ 2 - 2
src/views/sb/info/modules/SbInfoSelectModal.vue

@@ -16,7 +16,7 @@
                 <a-input v-model.trim="queryParam.keyword" placeholder="请输入名称/编码"/>
               </a-form-item>
             </a-col>
-<!--            <a-col :md="8" :sm="24">
+            <!--            <a-col :md="8" :sm="24">
               <a-form-item label="上层设备类型">
                 <a-tree-select
                   style="width: 100%"
@@ -280,7 +280,7 @@ export default {
       this.modalTitle = '选择设备'
       this.extraQueryParam = queryParam
       if (this.isCreated) {
-        this.setTree()
+        console.log(this.$refs.table)
         this.$refs.table.clearSelected()
         this.options.rowSelection.type = this.type
         this.handleOk()