“linengliang”
2023-08-29 78bdb5114382f006fb53fd461c7b90f4f43afc39
src/views/eam/modules/equipmentCategory/EquipmentCategoryModel.vue
@@ -1,7 +1,7 @@
<template>
  <a-modal
    :title="title"
    :width="1050"
    :width="1250"
    :visible="visible"
    :maskClosable="false"
    :confirmLoading="confirmLoading"
@@ -46,7 +46,7 @@
        </a-row>-->
        <a-row :gutter="24">
          <a-col :span="12">
          <a-col :span="24">
            <a-form-item
              label="设备分类编号"
              :labelCol="labelCol"
@@ -60,7 +60,9 @@
              />
            </a-form-item>
          </a-col>
          <a-col :span="12">
        </a-row>
        <a-row :gutter="24" v-if="parentId!='-1'">
          <a-col :span="24">
            <a-form-item
              label="设备分类名称"
              :labelCol="labelCol"
@@ -75,12 +77,66 @@
            </a-form-item>
          </a-col>
        </a-row>
       <a-row :gutter="24" v-if="parentId=='-1'">
          <a-col :span="24">
            <a-form-item
              label="设备分类名称"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
            >
            <j-dict-select-tag
                allow-clear
                :disabled="disableSubmit"
                :placeholder="disableSubmit?'':'请选择分类名称'"
                :triggerChange="true"
                dictCode="sys_dict_item,item_text,item_text,dict_id ='1695985281980776449'"
                v-decorator="['name', validatorRules.name ]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item
              :labelCol="{span:3}"
              :wrapperCol="{span:21}"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="分类标识"
            >
              <j-dict-select-tag
                allow-clear
                :disabled="disableSubmit"
                :placeholder="disableSubmit?'':'请选择分类标识'"
                :triggerChange="true"
                dictCode="equipment_category"
                v-decorator="['equipmentCategoryUda1', validatorRules.equipmentCategoryUda1]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="技术状态鉴定周期"
            >
            <j-dict-select-tag
                allow-clear
                :disabled="disableSubmit"
                :placeholder="disableSubmit?'':'请选择技术状态鉴定周期'"
                :triggerChange="true"
                dictCode="appraisal_cycle"
                v-decorator="['equipmentCategoryUda2', validatorRules.equipmentCategoryUda2]"
              />
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="24">
          <a-col :span="24">
            <a-form-item
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              label="备注"
            >
              <a-textarea
@@ -92,8 +148,39 @@
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
      <a-divider  v-if="title!='新增'" orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 选择子设备分类使其跟随父设备分类属性 </a-divider>
      <a-tabs
        type="card"
        defaultActiveKey="1"
        v-if="title!='新增'"
      >
      <a-tab-pane
          tab='子设备分类'
          key='1'
        >
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <a-table
      ref="table"
      bordered
      size="middle"
      rowKey="id"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      @change="handleTableChange"
      :scroll="{ x: true, y: 900 }"
     ></a-table>
    </a-tab-pane>
    </a-tabs>
    </a-spin>
    <template slot="footer">
@@ -126,9 +213,19 @@
import pick from 'lodash.pick'
import { postAction, requestPut } from '@/api/manage'
import { duplicateCheck } from '@/api/api'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
export default {
  name: 'EquipmentCategoryModel',
  mixins:[JeecgListMixin],
  props:{
    mainId:{
        type:String,
        default:'',
        required:false
    },
  },
  data() {
    return {
      title: "操作",
@@ -138,12 +235,10 @@
      parentId: '',
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 6 },
        span:3
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 18 },
        span:21
      },
      confirmLoading: false,
      form: this.$form.createForm(this),
@@ -162,16 +257,109 @@
            { validator: this.validateName },
          ]
        },
        equipmentCategoryUda1:{
          rules: [
            { required: true, message: '请选择类别标识!' },
          ]
        },
        remark: {
          rules: [
            { min: 0, max: 100, message: '长度不超过 100 个字符', trigger: 'blur' },
          ]
        },
        equipmentCategoryUda2:{
          rules: [
            { required: true, message: '请选择技术状态鉴定周期!' },
          ]
        }
      },
      url: {
        add: "/eam/equipmentCategory/add",
        edit: "/eam/equipmentCategory/edit"
        edit: "/eam/equipmentCategory/edit",
        list:"/eam/equipmentCategory/getAllChildren"
      },
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
          width: 50,
        },
      /*   {
          title: '上级设备分类编码',
          align: "center",
          dataIndex: 'parentNum',
          customRender:function(text, record){
              return record.parentName+text;
            }
          },
        {
          title: '上级设备分类名称',
          align: "center",
          dataIndex: 'parentName',
        }, */
        {
          title: '分类编码',
          align: "center",
          dataIndex: 'num',
          width: 220,
          // scopedSlots: {
          //   customRender: 'num',
          // },
          // sorter: true,
        },
        {
          title: '分类名称',
          align: "center",
          dataIndex: 'name',
          width: 220,
          // scopedSlots: {
          //   customRender: 'name',
          // },
          // sorter: true,
        },
        {
          title: '分类标识',
          align: "center",
          dataIndex: 'equipmentCategoryUda1_dictText',
          // scopedSlots: {
          //   customRender: 'name',
          // },
          // sorter: true,
          width: 220,
        },
        {
          title: '创建人',
          align: "center",
          dataIndex: 'createBy',
          width: 220,
        },
        {
          title: '创建时间',
          align: "center",
          dataIndex: 'createTime',
          width: 220,
        },
        {
          title: '修改人',
          align: "center",
          dataIndex: 'updateBy',
          width: 220,
        },
        {
          title: '修改时间',
          align: "center",
          dataIndex: 'updateTime',
          width: 220,
        },
      ],
      //新增、编辑、删除、批量删除操作改变数据后刷新关联的组件的监听属性
      alterFlag: ""
    }
@@ -190,7 +378,7 @@
      this.visible = true;
      this.disableSubmit = false;
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, 'parentNum', 'parentName', 'num', 'name', 'remark'))
        this.form.setFieldsValue(pick(this.model, 'parentNum','equipmentCategoryUda1','equipmentCategoryUda2', 'parentName', 'num', 'name', 'remark'))
      });
      if (record.id) {
        this.codeDisable = true;
@@ -202,6 +390,14 @@
    close() {
      this.$emit('close');
      this.visible = false;
    },
    onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
    },
    onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
    },
    //保存并新增按钮触发
@@ -244,6 +440,7 @@
            formData.parentId = this.parentId
            obj = postAction(this.url.add, formData);
          } else {
            formData.equipmentCategoryDtlList = this.selectionRows;
            obj = requestPut(this.url.edit, formData, { id: this.model.id });
          }
          obj.then((res) => {
@@ -256,6 +453,7 @@
            }
          }).finally(() => {
            that.confirmLoading = false;
            that.$bus.$emit('loadData')
            that.close();
          })
        }
@@ -303,12 +501,28 @@
        }
      })
    },
    clearList(){
        this.dataSource=[]
        this.selectedRowKeys=[]
        this.ipagination.current = 1
    }
  },
  watch: {
    alterFlag() {
      this.$bus.$emit('queryTreeData');
    },
    mainId:{
       immediate:true,
       handler(val) {
          if(!this.mainId){
            this.clearList()
          }else{
            this.queryParam['parentId'] = val
            this.loadData(1);
          }
        }
     },
  }
}
</script>