cuijian
2025-07-09 9b6bd0c014b73456edb095ee53b22324437ae646
src/views/tms/requirement/modules/ToolsModal.vue
@@ -0,0 +1,221 @@
<template>
  <a-modal :title="title" :width="1000" :visible="visible" :maskClosable="false" @ok="handleOk" @cancel="handleCancel"
           cancelText="关闭">
    <a-card :bordered="false">
      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="7" :sm="7">
              <a-form-item label="工具编码">
                <a-input placeholder="请输入工具编码检索" v-model="queryParam.toolId"></a-input>
              </a-form-item>
            </a-col>
            <a-col :md="3" :sm="3">
              <a-space>
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              </a-space>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <!-- table区域-begin -->
      <div>
        <a-table ref="table" size="middle" bordered rowKey="id" :scroll="{  y: 300 }" :columns="columns"
                 :dataSource="dataSource" :pagination="ipagination" :loading="loading"
                 :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'radio'}"
                 @change="handleTableChange">
        </a-table>
      </div>
      <!-- table区域-end -->
    </a-card>
  </a-modal>
</template>
<script>
import JDictSelectTag from '@/components/dict/JDictSelectTag'
import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@/components/jeecg/JInput'
import JEllipsis from '@/components/jeecg/JEllipsis'
import Tooltip from 'ant-design-vue/es/tooltip'
import JDate from '@/components/jeecg/JDate'
import { filterObj } from '@/utils/util'
export default {
  name: 'ToolsModal',
  mixins: [JeecgListMixin],
  components: {
    JDictSelectTag,
    JEllipsis,
    JInput,
    Tooltip,
    JDate
  },
  props: {
    status: {
      type: Number,
      default: 1
    }
  },
  data() {
    return {
      disableSubmit:false,
      title: '',
      visible: false,
      disableMixinCreated: true,
      queryParam: {},
      columns: [{
        title: '工具编码',
        align: 'center',
        dataIndex: 'toolId'
      },
        {
          title: '工具类型',
          align: 'center',
          dataIndex: 'applicationType_dictText'
        },
        // {
        //   title: '工具编号',
        //   align: 'center',
        //   dataIndex: 'toolId'
        // },
        {
          title: '中文名称',
          align: 'center',
          dataIndex: 'chineseName'
        },
        {
          title: '工具参数标识',
          align: 'center',
          dataIndex: 'paramaTableName_dictText'
        },
        {
          title: '型号/图号',
          align: 'center',
          dataIndex: 'toolModel'
        },
        {
          title: '主计量单位',
          align: 'center',
          dataIndex: 'mainUnit'
        }
      ],
      url: {
        list: '/tms/baseTools/listWithSharpedAndConfig'
      }
    }
  },
  created() {
  },
  methods: {
    showModals() {
      this.selectedRowKeys = []
      this.visible = true
      this.loadData(1)
    },
    getQueryParams() {
      //获取查询条件
      let sqp = {}
      if (this.superQueryParams) {
        sqp['superQueryParams'] = encodeURI(this.superQueryParams)
        sqp['superQueryMatchType'] = this.superQueryMatchType
      }
      var param = Object.assign(sqp, this.queryParam)
      // param.field = this.getQueryField();
      param.pageNo = this.ipagination.current
      param.pageSize = this.ipagination.pageSize
      return filterObj(param)
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error('请设置url.list属性!')
        return
      }
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1
      }
      var params = this.getQueryParams()//查询条件
      if (!params) {
        return false
      }
      this.loading = true
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records || res.result
          if (res.result.total) {
            this.ipagination.total = res.result.total
          } else {
            this.ipagination.total = 0
          }
        } else {
          // this.$message.warning(res.message)
          this.$notification.warning({
            message: '消息',
            description: res.message
          })
        }
      }).finally(() => {
        this.loading = false
      })
    },
    getQueryField() {
      //TODO 字段权限控制
      // var str = "";
      // this.columns.forEach(function (value) {
      //   str +=  value.dataIndex +"," ;
      // });
      // return str;
    },
    modalFormOk(val) {
      // 新增/修改 成功时,重载列表
      this.loadData()
      this.selectedRowKeys = [val.id]
    },
    searchQuery() {
      this.loadData()
      this.onClearSelected()
    },
    searchReset() {
      this.queryParam = {}
      this.loadData()
      this.onClearSelected()
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleCancel() {
      this.close()
    },
    handleOk() {
      this.$emit('sendSelectionRows', this.selectionRows[0])
      this.close()
    },
  }
}
</script>
<style>
@import '~@assets/less/common.less';
.frozenRowClass {
  color: #c9c9c9;
}
.success {
  color: green;
}
.error {
  color: red;
}
</style>