liuying
2024-04-23 82f7b3c19adfac9f2ccde3e09097d1c0b2cfd7ed
控制属性规则
已添加23个文件
已修改1个文件
3923 ■■■■■ 文件已修改
iWare_RawMaterialWarehouse_Web/src/api/modular/main/WmsBase/WmsControlRuleDetailManage.js 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/api/modular/main/WmsBase/WmsControlRuleManage.js 114 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/addForm.vue 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/details.vue 107 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/editForm.vue 123 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/excelForm.vue 181 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/index.vue 521 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/addForm.vue 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/editForm.vue 131 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/excelForm.vue 181 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/index.vue 604 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsMaterial/tabForm.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/Dto/WmsControlRuleInput.cs 166 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/Dto/WmsControlRuleOutput.cs 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/IWmsControlRuleService.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/Map/WmsControlRuleMapper.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/WmsControlRuleService.cs 418 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/Dto/WmsControlRuleDetailInput.cs 247 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/Dto/WmsControlRuleDetailOutput.cs 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/IWmsControlRuleDetailService.cs 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/Map/WmsControlRuleDetailMapper.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/WmsControlRuleDetailService.cs 592 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ExcelTemplateFile/WmsControlRuleDetailImport.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ExcelTemplateFile/WmsControlRuleImport.xlsx 补丁 | 查看 | 原始文档 | blame | 历史
iWare_RawMaterialWarehouse_Web/src/api/modular/main/WmsBase/WmsControlRuleDetailManage.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,114 @@
import { axios } from '@/utils/request'
/**
 * æŸ¥è¯¢æŽ§åˆ¶å±žæ€§è§„则明细
 *
 * @author ly
 */
export function WmsControlRuleDetailPage (parameter) {
  return axios({
    url: '/WmsControlRuleDetail/page',
    method: 'get',
    params: parameter
  })
}
/**
 * æŽ§åˆ¶å±žæ€§è§„则明细列表
 *
 * @author ly
 */
export function WmsControlRuleDetailList (parameter) {
  return axios({
    url: '/WmsControlRuleDetail/list',
    method: 'get',
    params: parameter
  })
}
/**
 * æ·»åŠ æŽ§åˆ¶å±žæ€§è§„åˆ™æ˜Žç»†
 *
 * @author ly
 */
export function WmsControlRuleDetailAdd (parameter) {
  return axios({
    url: '/WmsControlRuleDetail/add',
    method: 'post',
    data: parameter
  })
}
/**
 * ç¼–辑控制属性规则明细
 *
 * @author ly
 */
export function WmsControlRuleDetailEdit (parameter) {
  return axios({
    url: '/WmsControlRuleDetail/edit',
    method: 'post',
    data: parameter
  })
}
/**
 * åˆ é™¤æŽ§åˆ¶å±žæ€§è§„则明细
 *
 * @author ly
 */
export function WmsControlRuleDetailDelete (parameter) {
  return axios({
    url: '/WmsControlRuleDetail/delete',
    method: 'post',
    data: parameter
  })
}
/**
 * å¯¼å‡ºæŽ§åˆ¶å±žæ€§è§„则明细的Excel文件
 *
 * @author ly
 */
export function WmsControlRuleDetailToExcel (parameter) {
  return axios({
    url: '/WmsControlRuleDetail/toExcel',
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}
/**
 * å¯¼å…¥æŽ§åˆ¶å±žæ€§è§„则明细的Excel文件
 *
 * @author ly
 */
export function WmsControlRuleDetailImportExcel (data, parameter) {
  return axios({
    url: '/WmsControlRuleDetail/importExcel',
    method: 'post',
    data: data,
    params: parameter
  })
}
/**
 * ä¸‹è½½æŽ§åˆ¶å±žæ€§è§„则明细的Excel导入模板
 *
 * @author ly
 */
export function WmsControlRuleDetailDownloadExcelTemplate(parameter) {
  return axios({
    url: '/WmsControlRuleDetail/downloadExcelTemplate',
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}
iWare_RawMaterialWarehouse_Web/src/api/modular/main/WmsBase/WmsControlRuleManage.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,114 @@
import { axios } from '@/utils/request'
/**
 * æŸ¥è¯¢æŽ§åˆ¶å±žæ€§è§„则
 *
 * @author ly
 */
export function WmsControlRulePage (parameter) {
  return axios({
    url: '/WmsControlRule/page',
    method: 'get',
    params: parameter
  })
}
/**
 * æŽ§åˆ¶å±žæ€§è§„则列表
 *
 * @author ly
 */
export function WmsControlRuleList (parameter) {
  return axios({
    url: '/WmsControlRule/list',
    method: 'get',
    params: parameter
  })
}
/**
 * æ·»åŠ æŽ§åˆ¶å±žæ€§è§„åˆ™
 *
 * @author ly
 */
export function WmsControlRuleAdd (parameter) {
  return axios({
    url: '/WmsControlRule/add',
    method: 'post',
    data: parameter
  })
}
/**
 * ç¼–辑控制属性规则
 *
 * @author ly
 */
export function WmsControlRuleEdit (parameter) {
  return axios({
    url: '/WmsControlRule/edit',
    method: 'post',
    data: parameter
  })
}
/**
 * åˆ é™¤æŽ§åˆ¶å±žæ€§è§„则
 *
 * @author ly
 */
export function WmsControlRuleDelete (parameter) {
  return axios({
    url: '/WmsControlRule/delete',
    method: 'post',
    data: parameter
  })
}
/**
 * å¯¼å‡ºæŽ§åˆ¶å±žæ€§è§„则的Excel文件
 *
 * @author ly
 */
export function WmsControlRuleToExcel (parameter) {
  return axios({
    url: '/WmsControlRule/toExcel',
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}
/**
 * å¯¼å…¥æŽ§åˆ¶å±žæ€§è§„则的Excel文件
 *
 * @author ly
 */
export function WmsControlRuleImportExcel (data, parameter) {
  return axios({
    url: '/WmsControlRule/importExcel',
    method: 'post',
    data: data,
    params: parameter
  })
}
/**
 * ä¸‹è½½æŽ§åˆ¶å±žæ€§è§„则的Excel导入模板
 *
 * @author ly
 */
export function WmsControlRuleDownloadExcelTemplate(parameter) {
  return axios({
    url: '/WmsControlRule/downloadExcelTemplate',
    method: 'get',
    params: parameter,
    responseType: 'blob'
  })
}
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/addForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,94 @@
<template>
  <a-modal
    title="新增控制属性规则"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
        <a-form :form="form">
        <a-form-item label="规则编号" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入规则编号" v-decorator="['ruleCode', {rules: [{required: true, message: '请输入规则编号!'}]}]" />
        </a-form-item>
        <a-form-item label="规则名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入规则名称" v-decorator="['ruleName', {rules: [{required: true, message: '请输入规则名称!'}]}]" />
        </a-form-item>
        <a-form-item label="规则描述" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入规则描述" v-decorator="['ruleDesc']" />
        </a-form-item>
        <a-form-item label="是否禁用" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-switch v-decorator="['isDisabled',{rules: [{ required: true, message: '请选择是否禁用!' }], valuePropName: 'checked'}]" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
  import moment from 'moment'
  import {
  WmsControlRuleAdd
  } from '@/api/modular/main/WmsBase/WmsControlRuleManage'
  export default {
  data () {
  return {
  labelCol: {
  xs: { span: 24 },
  sm: { span: 5 }
  },
  wrapperCol: {
  xs: { span: 24 },
  sm: { span: 15 }
  },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
    moment,
      // åˆå§‹åŒ–方法
      add (record) {
        this.visible = true
        this.$nextTick(() => {
        });
      },
      /**
       * æäº¤è¡¨å•
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            WmsControlRuleAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败:' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/details.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,107 @@
<template>
  <!-- @ok="handleSubmit" -->
  <a-modal
    title="控制属性规则明细"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <control-rule-detail ref="controlRuleDetail" @ok="handleOk" />
    </a-spin>
  </a-modal>
</template>
<script>
import moment from 'moment'
import { WmsControlRuleEdit } from '@/api/modular/main/WmsBase/WmsControlRuleManage'
import ControlRuleDetail from '@/views/main/WmsBase/WmsControlRuleDetail/index.vue'
export default {
  components: {
    ControlRuleDetail
  },
  data() {
    return {
      Id: 0,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      record: {},
      visible: false,
      confirmLoading: false,
      form: this.$form.createForm(this)
    }
  },
  methods: {
    moment,
    // åˆå§‹åŒ–方法
    edit(record) {
      this.visible = true
      this.Id = record.id
      this.$nextTick(() => {})
      //深度拷贝 ç§»é™¤VUE的监听,防止INDEX页面值变动
      this.record = JSON.parse(JSON.stringify(record))
      this.$nextTick(() => {
        this.form.setFieldsValue({
          id: record.id,
          ruleCode: record.ruleCode,
          ruleName: record.ruleName,
          ruleDesc: record.ruleDesc,
          isDisabled: record.isDisabled
        })
      })
    },
    handleOk(){
    },
    handleSubmit() {
      const {
        form: { validateFields }
      } = this
      this.confirmLoading = true
      validateFields((errors, values) => {
        if (!errors) {
          for (const key in values) {
            if (values[key] == null) continue
            if (typeof values[key] === 'object') {
              values[key] = JSON.stringify(values[key])
              this.record[key] = values[key]
            } else {
              this.record[key] = values[key]
            }
          }
          WmsControlRuleEdit(this.record)
            .then(res => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', this.record)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败:' + JSON.stringify(res.message))
              }
            })
            .finally(res => {
              this.confirmLoading = false
            })
        } else {
          this.confirmLoading = false
        }
      })
    },
    handleCancel() {
      this.form.resetFields()
      this.visible = false
    }
  }
}
</script>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/editForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,123 @@
<template>
  <a-modal
    title="编辑控制属性规则"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="规则编号" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input
            placeholder="请输入规则编号"
            v-decorator="['ruleCode', { rules: [{ required: true, message: '请输入规则编号!' }] }]"
          />
        </a-form-item>
        <a-form-item label="规则名称" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input
            placeholder="请输入规则名称"
            v-decorator="['ruleName', { rules: [{ required: true, message: '请输入规则名称!' }] }]"
          />
        </a-form-item>
        <a-form-item label="规则描述" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入规则描述" v-decorator="['ruleDesc']" />
        </a-form-item>
        <a-form-item label="是否禁用" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-switch
            v-decorator="[
              'isDisabled',
              { rules: [{ required: true, message: '请选择是否禁用!' }], valuePropName: 'checked' }
            ]"
          />
        </a-form-item>
        <a-form-item v-show="false"><a-input v-decorator="['id']"/></a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
import moment from 'moment'
import { WmsControlRuleEdit } from '@/api/modular/main/WmsBase/WmsControlRuleManage'
export default {
  data() {
    return {
      Id: 0,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 15 }
      },
      record: {},
      visible: false,
      confirmLoading: false,
      form: this.$form.createForm(this)
    }
  },
  methods: {
    moment,
    // åˆå§‹åŒ–方法
    edit(record) {
      this.visible = true
      this.Id = record.id
      this.$nextTick(() => {})
      //深度拷贝 ç§»é™¤VUE的监听,防止INDEX页面值变动
      this.record = JSON.parse(JSON.stringify(record))
      this.$nextTick(() => {
        this.form.setFieldsValue({
          id: record.id,
          ruleCode: record.ruleCode,
          ruleName: record.ruleName,
          ruleDesc: record.ruleDesc,
          isDisabled: record.isDisabled
        })
      })
    },
    handleSubmit() {
      const {
        form: { validateFields }
      } = this
      this.confirmLoading = true
      validateFields((errors, values) => {
        if (!errors) {
          for (const key in values) {
            if (values[key] == null) continue
            if (typeof values[key] === 'object') {
              values[key] = JSON.stringify(values[key])
              this.record[key] = values[key]
            } else {
              this.record[key] = values[key]
            }
          }
          WmsControlRuleEdit(this.record)
            .then(res => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', this.record)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败:' + JSON.stringify(res.message))
              }
            })
            .finally(res => {
              this.confirmLoading = false
            })
        } else {
          this.confirmLoading = false
        }
      })
    },
    handleCancel() {
      this.form.resetFields()
      this.visible = false
    }
  }
}
</script>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/excelForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,181 @@
<template>
  <a-modal
    :width="850"
    :destroyOnClose="true"
    :visible="visible"
    :forceRender="true"
    title="批量导入"
    cancelText="取消上传"
    okText="开始上传"
    @cancel="handleCancel"
    @ok="handleSubmit">
    <a-spin :spinning="confirmLoading">
      <a-row :span="24">
        <span>请选择要导入的数据文件(Excel格式)</span>
      </a-row>
      <p></p>
      <a-row>
        <a-col :span="16">
          <a-upload-dragger accept=".xlsx,.xls" :multiple="false" :customRequest="customRequest" @change="handleChange" :beforeUpload="beforeUpload">
            <a-icon style="font-size: 40px;" type="cloud-upload" />
          </a-upload-dragger>
        </a-col>
        <!--<a-col :span="8">
          <span>导入模式:</span>
          <a-select
            style="width: 130px"
            placeholder="请选择导入模式"
            v-model="importExcelType">
            <a-select-option
              v-for="(item,index) in importExcelTypeData"
              :key="index"
              :value="item.code">{{ item.name }}
            </a-select-option>
          </a-select>
        </a-col>-->
      </a-row>
      <a-row :span="24">
        <!--<a-button @click="showDemand" style="width: 150px;text-align: left;" type="link" v-show="!detailed">
          ç‚¹å‡»æŸ¥çœ‹æ–‡ä»¶ä¸Šä¼ è¦æ±‚
        </a-button>-->
        <span>【</span>
        <a-button style="width: 90px;text-align: left;" @click="wmsControlRuleDownloadExcelTemplate" type="link">下载导入模板</a-button>,填写并上传
        <span>】</span>
        <a-button @click="showDemand" style="width: 150px;text-align: left;" type="link" v-show="detailed">
          æ”¶èµ·
        </a-button>
      </a-row>
      <a-row v-show="detailed" style="background: #fef4e8; height: 30px;" :span="24">
        <a-breadcrumb>
          <a-breadcrumb-item style="line-height: 30px;color: #faad14;margin-left: 18px;">文件上传要求</a-breadcrumb-item>
        </a-breadcrumb>
      </a-row>
      <pre v-show="detailed">
        <div v-html="demandText"></div>
      </pre>
      <a-table v-show="detailed" :columns="columns" :data-source="dataList" :rowKey="(record) => record.processID" :pagination="false"></a-table>
      <pre v-show="detailed">
        <div v-html="columnText"></div>
      </pre>
    </a-spin>
  </a-modal>
</template>
<script>
  import { downloadFile, checkFile, parseExcelFieldText, parseDemandText } from '@/utils/util'
  import { WmsControlRuleImportExcel, WmsControlRuleDownloadExcelTemplate} from '@/api/modular/main/WmsBase/WmsControlRuleManage'
  import { sysExcelTemplateGetColumnList } from '@/api/modular/system/excelTemplateManage'
  export default {
  components: {
  },
  data() {
  return {
  visible: false,
  detailed: false,
  confirmLoading: false,
  fileList: [],
  importExcelTypeData: [],
  importExcelType: '1',
  uploadFile: null,
  columns: [],
  dataList: [],
  demandText:'',
  columnText: ''
  }
  },
  methods: {
  index() {
  this.visible = true;
  this.importExcelTypeData = this.$options.filters['dictData']('import_excel_type')
  this.demandText = parseDemandText("wmsControlRuleDownloadExcelTemplate")
  window.downloadFile = this.wmsControlRuleDownloadExcelTemplate;
  this.getTable();
  },
  showDemand() {
  this.detailed = !this.detailed;
  },
  customRequest(document) {
  this.uploadFile = document
  },
  getTable() {
  sysExcelTemplateGetColumnList({className: "WmsControlRule"}).then(res =>
  {
  if (res.success) {
  this.columns =[];
  this.dataList = [{}];
  res.data.forEach(x => {
  this.columns.push({
  dataIndex: x.columnName,
  key: x.columnName,
  title: x.columnComment
  });
  this.dataList[0][x.columnName] = x.isRequired ? "必填" : "非必填"
  });
  this.columnText = parseExcelFieldText(res.data);
  }
  });
  },
  beforeUpload(fileInfo) {
  let res = checkFile(fileInfo, 1073741824, ['.xlsx', '.xls']);
  if (!res.success) {
  this.$message.warning(res.msg)
  return false
  }
  setTimeout(() => {this.uploadFile.onSuccess(this.uploadFile.file)}, 1000)
  },
  handleChange(fileInfo) {
  if (fileInfo.file.status === 'error') {
  fileInfo.fileList.splice(0, 1)
  }
  if (fileInfo.file.status === 'done') {
  if (fileInfo.fileList.length > 1) {
  fileInfo.fileList.splice(0, 1)
  }
  this.fileList = fileInfo.file
  }
  },
  handleSubmit() {
  this.confirmLoading = true
  const formData = new FormData()
  formData.append('file', this.uploadFile.file)
  WmsControlRuleImportExcel(formData, {importExcelType: this.importExcelType}).then(res => {
  this.$message.success('操作成功')
  this.confirmLoading = false
  this.$emit('ok', [])
  this.handleCancel()
  }).finally((res)=>{this.confirmLoading = false})
  },
  handleCancel() {
  this.visible = false
  this.detailed = false
  },
  wmsControlRuleDownloadExcelTemplate() {
  WmsControlRuleDownloadExcelTemplate({version: "v2"}).then((res) => {
  downloadFile(res);
  }).catch((err) => {
  this.$message.error('下载错误:获取文件流错误' + err)
  })
  }
  }
  }
</script>
<style scoped>
::v-deep .ant-upload.ant-upload-drag {
  position: relative;
  width: 140px;
  height: 135px;
  text-align: center;
  background: #fafafa;
  border: 1px dashed #d9d9d9;
  border-radius: 2px;
  cursor: pointer;
  -webkit-transition: border-color 0.3s;
  transition: border-color 0.3s;
}
::v-deep .ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger), .ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger) {
  color: #ffc53d;
  border-color: white;
}
</style>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRule/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,521 @@
<template>
  <!-- æŽ§åˆ¶å±žæ€§è§„则 -->
  <div ref="boxOutWrap" class="boxOutWrap">
    <div ref="boxForm" class="boxForm">
      <a-card :bordered="false" :bodyStyle="tstyle">
        <div class="table-page-search-wrapper" v-if="hasPerm('WmsControlRule:page')">
          <a-form layout="inline">
            <a-row :gutter="48">
              <a-col :md="8" :sm="24">
                <a-form-item label="规则编号">
                  <a-input v-model="queryParam.ruleCode" allow-clear placeholder="请输入规则编号" />
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="规则名称">
                  <a-input v-model="queryParam.ruleName" allow-clear placeholder="请输入规则名称" />
                </a-form-item> </a-col
              ><template v-if="advanced">
                <a-col :md="8" :sm="24">
                  <a-form-item label="规则描述">
                    <a-input v-model="queryParam.ruleDesc" allow-clear placeholder="请输入规则描述" />
                  </a-form-item>
                </a-col>
                <a-col :md="8" :sm="24">
                  <a-form-item label="是否禁用">
                    <a-select
                      :allowClear="true"
                      style="width: 100%"
                      v-model="queryParam.isDisabled"
                      placeholder="请选择是否禁用"
                    >
                      <a-select-option v-for="(item, index) in isDisabledData" :key="index" :value="item.code">{{
                        item.name
                      }}</a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
                <!--年月日时分秒-->
                <!--时间范围-->
                <a-col :md="8" :sm="24">
                  <a-form-item label="创建时间">
                    <a-range-picker
                      style="width: 100%"
                      :placeholder="['开始时间', '结束时间']"
                      :show-time="{
                        format: 'HH:mm:ss',
                        defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')]
                      }"
                      v-model="queryParam.createdTime"
                      value-format="YYYY-MM-DD HH:mm:ss"
                      format="YYYY-MM-DD HH:mm:ss"
                      @change="onChangecreatedTime"
                    />
                  </a-form-item>
                </a-col>
                <!--年月日时分秒-->
                <!--时间范围-->
                <a-col :md="8" :sm="24">
                  <a-form-item label="更新时间">
                    <a-range-picker
                      style="width: 100%"
                      :placeholder="['开始时间', '结束时间']"
                      :show-time="{
                        format: 'HH:mm:ss',
                        defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('23:59:59', 'HH:mm:ss')]
                      }"
                      v-model="queryParam.updatedTime"
                      value-format="YYYY-MM-DD HH:mm:ss"
                      format="YYYY-MM-DD HH:mm:ss"
                      @change="onChangeupdatedTime"
                    />
                  </a-form-item>
                </a-col>
                <a-col :md="8" :sm="24">
                  <a-form-item label="创建者名称">
                    <a-input v-model="queryParam.createdUserName" allow-clear placeholder="请输入创建者名称" />
                  </a-form-item>
                </a-col>
                <a-col :md="8" :sm="24">
                  <a-form-item label="修改者名称">
                    <a-input v-model="queryParam.updatedUserName" allow-clear placeholder="请输入修改者名称" />
                  </a-form-item>
                </a-col>
              </template>
              <a-col :md="8" :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="() => (queryParam = {})">重置</a-button>
                  <a @click="toggleAdvanced" style="margin-left: 8px">
                    {{ advanced ? '收起' : '展开' }}
                    <a-icon :type="advanced ? 'up' : 'down'" />
                  </a>
                </span>
              </a-col>
            </a-row>
          </a-form>
        </div>
      </a-card>
    </div>
    <a-card :bordered="false">
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
        :alert="true"
        @changeTablePage="pageInfo = $event"
        :scroll="{ x: true, y: tableHeight }"
        :rowKey="record => record.id"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
      >
        <template class="table-operator" slot="operator" v-if="hasPerm('WmsControlRule:add')">
          <div ref="actionBar" class="actionBar">
            <a-button
              type="info"
              v-if="hasPerm('sysExcelTemplate:importExcel')"
              icon="upload"
              @click="$refs.excelForm.index()"
            >
              å¯¼å…¥
            </a-button>
            <a-button
              type="info"
              v-if="hasPerm('WmsControlRule:exportExcel')"
              icon="download"
              @click="WmsControlRuleToExcel()"
            >
              å¯¼å‡º
            </a-button>
            <a-button type="primary" v-if="hasPerm('WmsControlRule:add')" icon="plus" @click="$refs.addForm.add()"
              >新增控制属性规则</a-button
            >
          </div>
        </template>
        <span slot="isDisabledscopedSlots" slot-scope="text">
          <div v-if="text === true">
            <a-tag color="green">是</a-tag>
          </div>
          <div v-else-if="text == false">
            <a-tag color="volcano">否</a-tag>
          </div>
          <div v-else=""></div>
        </span>
        <span slot="action" slot-scope="text, record">
          <!-- è‡ªå®šä¹‰ -->
          <a v-if="hasPerm('WmsControlRule:getdetail')" @click="$refs.detailForm.edit(record)">详情</a>
          &nbsp;&nbsp;
          <a v-if="hasPerm('WmsControlRule:edit')" @click="$refs.editForm.edit(record)">编辑</a>
          <a-divider type="vertical" v-if="hasPerm('WmsControlRule:edit') & hasPerm('WmsControlRule:delete')" />
          <a-popconfirm
            v-if="hasPerm('WmsControlRule:delete')"
            placement="topRight"
            title="确认删除?"
            @confirm="() => WmsControlRuleDelete(record)"
          >
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
      <add-form ref="addForm" @ok="handleOk" />
      <edit-form ref="editForm" @ok="handleOk" />
      <excel-form ref="excelForm" @ok="handleOk" />
      <!-- è‡ªå®šä¹‰ -->
      <detail-form ref="detailForm" @ok="handleOk" />
    </a-card>
  </div>
</template>
<script>
import { STable } from '@/components'
import moment from 'moment'
import {
  WmsControlRulePage,
  WmsControlRuleDelete,
  WmsControlRuleToExcel
} from '@/api/modular/main/WmsBase/WmsControlRuleManage'
//自定义table高度
import setTableHtMixin from '@/mixins/handleTableHt.js'
import addForm from './addForm.vue'
import { exportExcel } from '@/utils/exportToExcel'
import { downloadFile } from '@/utils/util'
import editForm from './editForm.vue'
import excelForm from './excelForm.vue'
import detailForm from './details.vue'
export default {
  mixins: [setTableHtMixin],
  components: {
    STable,
    addForm,
    editForm,
    excelForm,
    detailForm
  },
  data() {
    return {
      advanced: false, // é«˜çº§æœç´¢ å±•å¼€/关闭
      queryParam: {},
      pageInfo: {
        current: 1,
        pageSize: 10
      },
      columns: [
        {
          title: '序号',
          width: '60px',
          align: 'center',
          customRender: (text, record, index) => `${index + 1 + (this.pageInfo.current - 1) * this.pageInfo.pageSize}`
        },
        {
          title: '规则编号',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'ruleCode'
        },
        {
          title: '规则名称',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'ruleName'
        },
        {
          title: '规则描述',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'ruleDesc'
        },
        {
          title: '是否禁用',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'isDisabled',
          scopedSlots: { customRender: 'isDisabledscopedSlots' }
        },
        {
          title: '创建时间',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'createdTime'
        },
        {
          title: '更新时间',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'updatedTime'
        },
        {
          title: '创建者名称',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'createdUserName'
        },
        {
          title: '修改者名称',
          align: 'center',
          customHeaderCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          customCell: () => {
            return {
              style: {
                'min-width': '120px' //最小列宽设置
              }
            }
          },
          sorter: true,
          dataIndex: 'updatedUserName'
        }
      ],
      tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
      // åŠ è½½æ•°æ®æ–¹æ³• å¿…须为 Promise å¯¹è±¡
      loadData: parameter => {
        return WmsControlRulePage(Object.assign(parameter, this.switchingDate())).then(res => {
          return res.data
        })
      },
      selectedRowKeys: [],
      selectedRows: []
    }
  },
  created() {
    if (this.hasPerm('WmsControlRule:edit') || this.hasPerm('WmsControlRule:delete')) {
      this.columns.push({
        title: '操作',
        width: '150px',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
      })
    }
    const path = this.$route.path
    const columnStr = window.localStorage.getItem(path)
    if (columnStr) {
      var _columns = JSON.parse(columnStr)
      this.columns.forEach(element => {
        var fObj = _columns.find((item, index) => {
          return item.dataIndex === element.dataIndex
        })
        if (fObj != undefined && fObj != null) {
          element.checked = fObj.checked
        }
      })
    }
    const isDisabledOption = this.$options
    this.isDisabledData = isDisabledOption.filters['dictData']('yes_true_false')
    this.handleTableHt() //设置主表表格高度
    window.addEventListener(
      'resize',
      () => {
        this.handleTableHt() // ç›‘听屏幕大小改变表格高度
      },
      false
    )
  },
  methods: {
    moment,
    /**
     * æŸ¥è¯¢å‚数组装
     */
    switchingDate() {
      const obj = JSON.parse(JSON.stringify(this.queryParam))
      return obj
    },
    WmsControlRuleDelete(record) {
      WmsControlRuleDelete(record).then(res => {
        if (res.success) {
          this.$message.success('删除成功')
          this.$refs.table.refresh()
        } else {
          this.$message.error('删除失败') // + res.message
        }
      })
    },
    WmsControlRuleToExcel() {
      this.loading = true
      let entozh = {}
      const path = this.$route.path
      if (window.localStorage.getItem(path)) {
        JSON.parse(window.localStorage.getItem(path)).forEach(item => {
          if (item.dataIndex != 'action' && item.checked) {
            entozh[item.dataIndex] = item.title
          }
        })
      } else {
        //直接点导出
        this.columns.forEach(item => {
          if (item.dataIndex != 'action') {
            entozh[item.dataIndex] = item.title
          }
        })
      }
      WmsControlRulePage(Object.assign({ pageSize: 100000, pageIndex: 1 }, this.queryParam))
        .then(res => {
          this.loading = false
          //需要截取日期的字段
          var arrDataCutout = this.columns.filter(v => v.customCutout == true)
          res.data.rows.forEach(item => {
            var arrKeys = Object.keys(item)
            arrKeys.forEach(key => {
              var strFieldDic = key + 'Data'
              //枚举转值
              if (this[strFieldDic] && this[strFieldDic].length > 0) {
                let arrFieldDic = this[strFieldDic].filter(v => String(v.code) == String(item[key]))
                if (arrFieldDic.length > 0) {
                  item[key] = arrFieldDic[0]?.name || '没有枚举值'
                }
              }
              // æ—¥æœŸæˆªå–
              if (arrDataCutout.length > 0) {
                arrDataCutout.forEach(itemIn => {
                  if (key == itemIn.dataIndex && item[key]) {
                    item[key] = item[key].split(' ')[0]
                  }
                })
              }
            })
          })
          exportExcel(res.data.rows, entozh, 'xlsx', `${this.$route.meta.title}`)
        })
        .catch(err => {
          this.loading = false
          this.$message.error('下载错误:获取文件流错误' + err)
        })
    },
    toggleAdvanced() {
      this.advanced = !this.advanced
      this.handleTableHt() //设置主表表格高度
    },
    onChangecreatedTime(date, dateString) {
      this.queryParam.createdTime = dateString
    },
    onChangeupdatedTime(date, dateString) {
      this.queryParam.updatedTime = dateString
    },
    handleOk() {
      this.$refs.table.refresh()
    },
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    }
  }
}
</script>
<style lang="less">
.table-operator {
  margin-bottom: 18px;
}
button {
  margin-right: 8px;
}
</style>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/addForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,109 @@
<template>
  <a-modal
    title="新增控制属性规则明细"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
        <a-form :form="form">
        <a-form-item label="控制属性规则ID" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入控制属性规则ID" v-decorator="['controlRuleId', {rules: [{required: true, message: '请输入控制属性规则ID!'}]}]" />
        </a-form-item>
        <a-form-item label="最高库存" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最高库存" v-decorator="['maxImumqty', {rules: [{required: true, message: '请输入最高库存!'}]}]" />
        </a-form-item>
        <a-form-item label="最低库存" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最低库存" v-decorator="['minImumqty', {rules: [{required: true, message: '请输入最低库存!'}]}]" />
        </a-form-item>
        <a-form-item label="安全库存" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入安全库存" v-decorator="['safeImumqty', {rules: [{required: true, message: '请输入安全库存!'}]}]" />
        </a-form-item>
        <a-form-item label="最小库龄" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最小库龄" v-decorator="['minStorageAge', {rules: [{required: true, message: '请输入最小库龄!'}]}]" />
        </a-form-item>
        <a-form-item label="最大库龄" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最大库龄" v-decorator="['maxStorageAge', {rules: [{required: true, message: '请输入最大库龄!'}]}]" />
        </a-form-item>
        <a-form-item label="是否免检" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-switch v-decorator="['isNotChek',{rules: [{ required: true, message: '请选择是否免检!' }], valuePropName: 'checked'}]" />
        </a-form-item>
        <a-form-item label="保质期天数" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入保质期天数" v-decorator="['shelfLifeDays', {rules: [{required: true, message: '请输入保质期天数!'}]}]" />
        </a-form-item>
        <a-form-item label="是否禁用" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-switch v-decorator="['isDisabled',{rules: [{ required: true, message: '请选择是否禁用!' }], valuePropName: 'checked'}]" />
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
  import moment from 'moment'
  import {
  WmsControlRuleDetailAdd
  } from '@/api/modular/main/WmsBase/WmsControlRuleDetailManage'
  export default {
  data () {
  return {
  labelCol: {
  xs: { span: 24 },
  sm: { span: 5 }
  },
  wrapperCol: {
  xs: { span: 24 },
  sm: { span: 15 }
  },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
    moment,
      // åˆå§‹åŒ–方法
      add (record) {
        this.visible = true
        this.$nextTick(() => {
        });
      },
      /**
       * æäº¤è¡¨å•
       */
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            WmsControlRuleDetailAdd(values).then((res) => {
              if (res.success) {
                this.$message.success('新增成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('新增失败:' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/editForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,131 @@
<template>
  <a-modal
    title="编辑控制属性规则明细"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="控制属性规则ID" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入控制属性规则ID" v-decorator="['controlRuleId', {rules: [{required: true, message: '请输入控制属性规则ID!'}]}]" />
        </a-form-item>
        <a-form-item label="最高库存" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最高库存" v-decorator="['maxImumqty', {rules: [{required: true, message: '请输入最高库存!'}]}]" />
        </a-form-item>
        <a-form-item label="最低库存" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最低库存" v-decorator="['minImumqty', {rules: [{required: true, message: '请输入最低库存!'}]}]" />
        </a-form-item>
        <a-form-item label="安全库存" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入安全库存" v-decorator="['safeImumqty', {rules: [{required: true, message: '请输入安全库存!'}]}]" />
        </a-form-item>
        <a-form-item label="最小库龄" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最小库龄" v-decorator="['minStorageAge', {rules: [{required: true, message: '请输入最小库龄!'}]}]" />
        </a-form-item>
        <a-form-item label="最大库龄" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入最大库龄" v-decorator="['maxStorageAge', {rules: [{required: true, message: '请输入最大库龄!'}]}]" />
        </a-form-item>
        <a-form-item label="是否免检" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-switch v-decorator="['isNotChek',{rules: [{ required: true, message: '请选择是否免检!' }], valuePropName: 'checked'}]" />
        </a-form-item>
        <a-form-item label="保质期天数" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入保质期天数" v-decorator="['shelfLifeDays', {rules: [{required: true, message: '请输入保质期天数!'}]}]" />
        </a-form-item>
        <a-form-item label="是否禁用" :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-switch v-decorator="['isDisabled',{rules: [{ required: true, message: '请选择是否禁用!' }], valuePropName: 'checked'}]" />
        </a-form-item>
        <a-form-item v-show="false"><a-input v-decorator="['id']" /></a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>
<script>
import moment from 'moment'
  import {
  WmsControlRuleDetailEdit
  } from '@/api/modular/main/WmsBase/WmsControlRuleDetailManage'
  export default {
  data () {
  return {
  Id: 0,
  labelCol: {
  xs: { span: 24 },
  sm: { span: 5 }
  },
  wrapperCol: {
  xs: { span: 24 },
  sm: { span: 15 }
  },
  record: {},
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
    moment,
      // åˆå§‹åŒ–方法
      edit (record) {
        this.visible = true;
        this.Id = record.id;
        this.$nextTick(() => {
        });
        //深度拷贝 ç§»é™¤VUE的监听,防止INDEX页面值变动
        this.record = JSON.parse(JSON.stringify(record))
        this.$nextTick(() => {
          this.form.setFieldsValue(
            {
              id: record.id,
              controlRuleId: record.controlRuleId,
              maxImumqty: record.maxImumqty,
              minImumqty: record.minImumqty,
              safeImumqty: record.safeImumqty,
              minStorageAge: record.minStorageAge,
              maxStorageAge: record.maxStorageAge,
              isNotChek: record.isNotChek,
              shelfLifeDays: record.shelfLifeDays,
              isDisabled: record.isDisabled
            }
          )
        })
      },
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (values[key] == null) continue
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
                 this.record[key] = values[key]
              } else {
                 this.record[key] = values[key]
              }
            }
            WmsControlRuleDetailEdit(this.record).then((res) => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', this.record)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败:' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          }else{
            this.confirmLoading = false
          }
        });
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/excelForm.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,181 @@
<template>
  <a-modal
    :width="850"
    :destroyOnClose="true"
    :visible="visible"
    :forceRender="true"
    title="批量导入"
    cancelText="取消上传"
    okText="开始上传"
    @cancel="handleCancel"
    @ok="handleSubmit">
    <a-spin :spinning="confirmLoading">
      <a-row :span="24">
        <span>请选择要导入的数据文件(Excel格式)</span>
      </a-row>
      <p></p>
      <a-row>
        <a-col :span="16">
          <a-upload-dragger accept=".xlsx,.xls" :multiple="false" :customRequest="customRequest" @change="handleChange" :beforeUpload="beforeUpload">
            <a-icon style="font-size: 40px;" type="cloud-upload" />
          </a-upload-dragger>
        </a-col>
        <!--<a-col :span="8">
          <span>导入模式:</span>
          <a-select
            style="width: 130px"
            placeholder="请选择导入模式"
            v-model="importExcelType">
            <a-select-option
              v-for="(item,index) in importExcelTypeData"
              :key="index"
              :value="item.code">{{ item.name }}
            </a-select-option>
          </a-select>
        </a-col>-->
      </a-row>
      <a-row :span="24">
        <!--<a-button @click="showDemand" style="width: 150px;text-align: left;" type="link" v-show="!detailed">
          ç‚¹å‡»æŸ¥çœ‹æ–‡ä»¶ä¸Šä¼ è¦æ±‚
        </a-button>-->
        <span>【</span>
        <a-button style="width: 90px;text-align: left;" @click="wmsControlRuleDetailDownloadExcelTemplate" type="link">下载导入模板</a-button>,填写并上传
        <span>】</span>
        <a-button @click="showDemand" style="width: 150px;text-align: left;" type="link" v-show="detailed">
          æ”¶èµ·
        </a-button>
      </a-row>
      <a-row v-show="detailed" style="background: #fef4e8; height: 30px;" :span="24">
        <a-breadcrumb>
          <a-breadcrumb-item style="line-height: 30px;color: #faad14;margin-left: 18px;">文件上传要求</a-breadcrumb-item>
        </a-breadcrumb>
      </a-row>
      <pre v-show="detailed">
        <div v-html="demandText"></div>
      </pre>
      <a-table v-show="detailed" :columns="columns" :data-source="dataList" :rowKey="(record) => record.processID" :pagination="false"></a-table>
      <pre v-show="detailed">
        <div v-html="columnText"></div>
      </pre>
    </a-spin>
  </a-modal>
</template>
<script>
  import { downloadFile, checkFile, parseExcelFieldText, parseDemandText } from '@/utils/util'
  import { WmsControlRuleDetailImportExcel, WmsControlRuleDetailDownloadExcelTemplate} from '@/api/modular/main/WmsBase/WmsControlRuleDetailManage'
  import { sysExcelTemplateGetColumnList } from '@/api/modular/system/excelTemplateManage'
  export default {
  components: {
  },
  data() {
  return {
  visible: false,
  detailed: false,
  confirmLoading: false,
  fileList: [],
  importExcelTypeData: [],
  importExcelType: '1',
  uploadFile: null,
  columns: [],
  dataList: [],
  demandText:'',
  columnText: ''
  }
  },
  methods: {
  index() {
  this.visible = true;
  this.importExcelTypeData = this.$options.filters['dictData']('import_excel_type')
  this.demandText = parseDemandText("wmsControlRuleDetailDownloadExcelTemplate")
  window.downloadFile = this.wmsControlRuleDetailDownloadExcelTemplate;
  this.getTable();
  },
  showDemand() {
  this.detailed = !this.detailed;
  },
  customRequest(document) {
  this.uploadFile = document
  },
  getTable() {
  sysExcelTemplateGetColumnList({className: "WmsControlRuleDetail"}).then(res =>
  {
  if (res.success) {
  this.columns =[];
  this.dataList = [{}];
  res.data.forEach(x => {
  this.columns.push({
  dataIndex: x.columnName,
  key: x.columnName,
  title: x.columnComment
  });
  this.dataList[0][x.columnName] = x.isRequired ? "必填" : "非必填"
  });
  this.columnText = parseExcelFieldText(res.data);
  }
  });
  },
  beforeUpload(fileInfo) {
  let res = checkFile(fileInfo, 1073741824, ['.xlsx', '.xls']);
  if (!res.success) {
  this.$message.warning(res.msg)
  return false
  }
  setTimeout(() => {this.uploadFile.onSuccess(this.uploadFile.file)}, 1000)
  },
  handleChange(fileInfo) {
  if (fileInfo.file.status === 'error') {
  fileInfo.fileList.splice(0, 1)
  }
  if (fileInfo.file.status === 'done') {
  if (fileInfo.fileList.length > 1) {
  fileInfo.fileList.splice(0, 1)
  }
  this.fileList = fileInfo.file
  }
  },
  handleSubmit() {
  this.confirmLoading = true
  const formData = new FormData()
  formData.append('file', this.uploadFile.file)
  WmsControlRuleDetailImportExcel(formData, {importExcelType: this.importExcelType}).then(res => {
  this.$message.success('操作成功')
  this.confirmLoading = false
  this.$emit('ok', [])
  this.handleCancel()
  }).finally((res)=>{this.confirmLoading = false})
  },
  handleCancel() {
  this.visible = false
  this.detailed = false
  },
  wmsControlRuleDetailDownloadExcelTemplate() {
  WmsControlRuleDetailDownloadExcelTemplate({version: "v2"}).then((res) => {
  downloadFile(res);
  }).catch((err) => {
  this.$message.error('下载错误:获取文件流错误' + err)
  })
  }
  }
  }
</script>
<style scoped>
::v-deep .ant-upload.ant-upload-drag {
  position: relative;
  width: 140px;
  height: 135px;
  text-align: center;
  background: #fafafa;
  border: 1px dashed #d9d9d9;
  border-radius: 2px;
  cursor: pointer;
  -webkit-transition: border-color 0.3s;
  transition: border-color 0.3s;
}
::v-deep .ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger), .ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger) {
  color: #ffc53d;
  border-color: white;
}
</style>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsControlRuleDetail/index.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,604 @@
<template>
  <div ref="boxOutWrap" class="boxOutWrap">
    <div ref="boxForm" class="boxForm">
    <a-card :bordered="false" :bodyStyle="tstyle">
      <div class="table-page-search-wrapper" v-if="hasPerm('WmsControlRuleDetail:page')">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="控制属性规则ID">
                <a-input v-model="queryParam.controlRuleId" allow-clear placeholder="请输入控制属性规则ID"/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="最高库存">
                <a-input v-model="queryParam.maxImumqty" allow-clear placeholder="请输入最高库存"/>
              </a-form-item>
            </a-col><template v-if="advanced">
              <a-col :md="8" :sm="24">
                <a-form-item label="最低库存">
                  <a-input v-model="queryParam.minImumqty" allow-clear placeholder="请输入最低库存"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="安全库存">
                  <a-input v-model="queryParam.safeImumqty" allow-clear placeholder="请输入安全库存"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="最小库龄">
                  <a-input v-model="queryParam.minStorageAge" allow-clear placeholder="请输入最小库龄"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="最大库龄">
                  <a-input v-model="queryParam.maxStorageAge" allow-clear placeholder="请输入最大库龄"/>
                </a-form-item>
              </a-col>
            <a-col :md="8" :sm="24">
                <a-form-item label="是否免检">
                    <a-select :allowClear="true" style="width: 100%" v-model="queryParam.isNotChek" placeholder="请选择是否免检">
                        <a-select-option v-for="(item,index) in isNotChekData" :key="index" :value="item.code">{{ item.name }}</a-select-option>
                    </a-select>
                </a-form-item>
            </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="保质期天数">
                  <a-input v-model="queryParam.shelfLifeDays" allow-clear placeholder="请输入保质期天数"/>
                </a-form-item>
              </a-col>
            <a-col :md="8" :sm="24">
                <a-form-item label="是否禁用">
                    <a-select :allowClear="true" style="width: 100%" v-model="queryParam.isDisabled" placeholder="请选择是否禁用">
                        <a-select-option v-for="(item,index) in isDisabledData" :key="index" :value="item.code">{{ item.name }}</a-select-option>
                    </a-select>
                </a-form-item>
            </a-col>
                  <!--年月日时分秒-->
            <!--时间范围-->
                <a-col :md="8" :sm="24">
                    <a-form-item label="创建时间">
                        <a-range-picker style="width: 100%" :placeholder="['开始时间', '结束时间']"  :show-time="{
format: 'HH:mm:ss',  defaultValue: [moment('00:00:00', 'HH:mm:ss'),moment('23:59:59', 'HH:mm:ss')]}" v-model="queryParam.createdTime"  value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"   @change="onChangecreatedTime"/>
                    </a-form-item>
                </a-col>
                      <!--年月日时分秒-->
            <!--时间范围-->
                <a-col :md="8" :sm="24">
                    <a-form-item label="更新时间">
                        <a-range-picker style="width: 100%" :placeholder="['开始时间', '结束时间']"  :show-time="{
format: 'HH:mm:ss',  defaultValue: [moment('00:00:00', 'HH:mm:ss'),moment('23:59:59', 'HH:mm:ss')]}" v-model="queryParam.updatedTime"  value-format="YYYY-MM-DD HH:mm:ss" format="YYYY-MM-DD HH:mm:ss"   @change="onChangeupdatedTime"/>
                    </a-form-item>
                </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="创建者名称">
                  <a-input v-model="queryParam.createdUserName" allow-clear placeholder="请输入创建者名称"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="修改者名称">
                  <a-input v-model="queryParam.updatedUserName" allow-clear placeholder="请输入修改者名称"/>
                </a-form-item>
              </a-col>    </template>
            <a-col :md="8" :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="() => queryParam = {}">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px"> {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>
          </a-row>
        </a-form>
      </div>
    </a-card>
    </div>
    <a-card :bordered="false">
        <!-- :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }" -->
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
        :alert="true"
        @changeTablePage="pageInfo = $event"
        :scroll="{x: true,y:tableHeight}"
        :rowKey="(record) => record.id"
        >
        <template class="table-operator" slot="operator" v-if="hasPerm('WmsControlRuleDetail:add')" >
        <div ref="actionBar" class="actionBar">
            <a-button type="info" v-if="hasPerm('sysExcelTemplate:importExcel')" icon="upload" @click="$refs.excelForm.index()">
            å¯¼å…¥
          </a-button>
          <a-button type="info" v-if="hasPerm('WmsControlRuleDetail:exportExcel')" icon="download" @click="WmsControlRuleDetailToExcel()">
            å¯¼å‡º
          </a-button>
            <a-button type="primary" v-if="hasPerm('WmsControlRuleDetail:add')" icon="plus" @click="$refs.addForm.add()">新增控制属性规则明细</a-button>
        </div>
        </template>
          <span slot="isNotChekscopedSlots" slot-scope="text">
            <div v-if="text===true ">
                <a-tag color="green">是</a-tag>
            </div>
            <div v-else-if="text==false">
                <a-tag color="volcano">否</a-tag>
            </div>
            <div v-else=""></div>
            </span>
          <span slot="isDisabledscopedSlots" slot-scope="text">
            <div v-if="text===true ">
                <a-tag color="green">是</a-tag>
            </div>
            <div v-else-if="text==false">
                <a-tag color="volcano">否</a-tag>
            </div>
            <div v-else=""></div>
            </span>
          <span slot="action" slot-scope="text, record">
            <a v-if="hasPerm('WmsControlRuleDetail:edit')" @click="$refs.editForm.edit(record)">编辑</a>
          <a-divider type="vertical" v-if="hasPerm('WmsControlRuleDetail:edit') & hasPerm('WmsControlRuleDetail:delete')"/>
          <a-popconfirm v-if="hasPerm('WmsControlRuleDetail:delete')" placement="topRight" title="确认删除?" @confirm="() => WmsControlRuleDetailDelete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
      <add-form ref="addForm" @ok="handleOk" />
      <edit-form ref="editForm" @ok="handleOk" />
      <excel-form ref="excelForm" @ok="handleOk" />
    </a-card>
  </div>
</template>
<script>
    import { STable } from '@/components'
    import moment from 'moment'
    import { WmsControlRuleDetailPage, WmsControlRuleDetailDelete, WmsControlRuleDetailToExcel } from '@/api/modular/main/WmsBase/WmsControlRuleDetailManage'
    //自定义table高度
    import setTableHtMixin from '@/mixins/handleTableHt.js'
    import addForm from './addForm.vue'
    import { exportExcel } from '@/utils/exportToExcel'
    import { downloadFile } from '@/utils/util'
    import editForm from './editForm.vue'
    import excelForm from './excelForm.vue'
    export default {
    mixins: [setTableHtMixin],
    components: {
    STable,
    addForm,
    editForm,
    excelForm
    },
    data () {
    return {
    advanced: false, // é«˜çº§æœç´¢ å±•å¼€/关闭
    queryParam: {},
     pageInfo: {
        current: 1,
        pageSize: 10
      },
    columns: [
    {
    title:'序号',
    width: '60px',
    align: 'center',
    customRender: (text, record, index) => `${index + 1 + (this.pageInfo.current - 1) * this.pageInfo.pageSize}`
    },
    {
    title: '控制属性规则ID',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '140px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '140px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'controlRuleId'
    },
    {
    title: '最高库存',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'maxImumqty'
    },
    {
    title: '最低库存',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'minImumqty'
    },
    {
    title: '安全库存',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'safeImumqty'
    },
    {
    title: '最小库龄',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'minStorageAge'
    },
    {
    title: '最大库龄',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'maxStorageAge'
    },
    {
    title: '是否免检',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'isNotChek',
    scopedSlots: { customRender: 'isNotChekscopedSlots' }
    },
    {
    title: '保质期天数',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'shelfLifeDays'
    },
    {
    title: '是否禁用',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'isDisabled',
    scopedSlots: { customRender: 'isDisabledscopedSlots' }
    },
    {
    title: '创建时间',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'createdTime'
    },
    {
    title: '更新时间',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'updatedTime'
    },
    {
    title: '创建者名称',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'createdUserName'
    },
    {
    title: '修改者名称',
    align: 'center',
    customHeaderCell: () => {
    return {
     style: {
    'min-width': '120px'//最小列宽设置
     }
     }
    },
    customCell: () => {
    return {
    style: {
    'min-width': '120px'//最小列宽设置
    }
    }
    },
    sorter: true,
    dataIndex: 'updatedUserName'
    }
    ],
    tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
    // åŠ è½½æ•°æ®æ–¹æ³• å¿…须为 Promise å¯¹è±¡
    loadData: parameter => {
    return WmsControlRuleDetailPage(Object.assign(parameter, this.switchingDate())).then((res) => {
    return res.data
    })
    },
    selectedRowKeys: [],
    selectedRows: []
    }
    },
    created () {
    if (this.hasPerm('WmsControlRuleDetail:edit') || this.hasPerm('WmsControlRuleDetail:delete')) {
    this.columns.push({
    title: '操作',
    width: '150px',
    dataIndex: 'action',
    scopedSlots: { customRender: 'action' }
    })
    }
    const path = this.$route.path
    const columnStr = window.localStorage.getItem(path)
    if(columnStr) {
    var _columns = JSON.parse(columnStr)
    this.columns.forEach(element => {
    var fObj = _columns.find((item, index) => {
    return item.dataIndex === element.dataIndex;
    })
    if(fObj!=undefined && fObj!=null){
    element.checked=fObj.checked;
    }
    });
    }
    const isNotChekOption = this.$options
    this.isNotChekData = isNotChekOption.filters['dictData']('yes_true_false')
    const isDisabledOption = this.$options
    this.isDisabledData = isDisabledOption.filters['dictData']('yes_true_false')
    this.handleTableHt() //设置主表表格高度
    window.addEventListener(
    'resize',
    () => {
    this.handleTableHt() // ç›‘听屏幕大小改变表格高度
    },
    false
    )
    },
    methods: {
    moment,
    /**
    * æŸ¥è¯¢å‚数组装
    */
    switchingDate () {
    const obj = JSON.parse(JSON.stringify(this.queryParam))
    return obj
    },
    WmsControlRuleDetailDelete (record) {
    WmsControlRuleDetailDelete(record).then((res) => {
    if (res.success) {
    this.$message.success('删除成功')
    this.$refs.table.refresh()
    } else {
    this.$message.error('删除失败') // + res.message
    }
    })
    },
    WmsControlRuleDetailToExcel() {
    this.loading = true
    let entozh = {};
    const path = this.$route.path;
    if (window.localStorage.getItem(path)) {
    JSON.parse(window.localStorage.getItem(path)).forEach(item => {
    if (item.dataIndex != 'action' && item.checked) {
    entozh[item.dataIndex] = item.title
    }
    })
    } else { //直接点导出
    this.columns.forEach(item => {
    if (item.dataIndex != 'action') {
    entozh[item.dataIndex] = item.title
    }
    })
    }
    WmsControlRuleDetailPage(Object.assign({ pageSize: 100000, pageIndex: 1 }, this.queryParam)).then((res) => {
    this.loading = false;
    //需要截取日期的字段
    var arrDataCutout = this.columns.filter(v => v.customCutout == true);
    res.data.rows.forEach(item => {
    var arrKeys = Object.keys(item);
    arrKeys.forEach(key => {
    var strFieldDic = key + 'Data';
    //枚举转值
    if (this[strFieldDic] && this[strFieldDic].length > 0) {
    let arrFieldDic = this[strFieldDic].filter(v => String(v.code) == String(item[key]));
    if (arrFieldDic.length > 0) {
    item[key] = arrFieldDic[0]?.name || '没有枚举值';
    }
    }
    // æ—¥æœŸæˆªå–
    if (arrDataCutout.length > 0) {
    arrDataCutout.forEach(itemIn => {
    if (key == itemIn.dataIndex && item[key]) {
    item[key] = item[key].split(" ")[0]
    }
    })
    }
    });
    })
    exportExcel(res.data.rows, entozh, "xlsx", `${this.$route.meta.title}`)
    }).catch((err) => {
    this.loading = false
    this.$message.error('下载错误:获取文件流错误' + err)
    })
    },
    toggleAdvanced () {
    this.advanced = !this.advanced
    this.handleTableHt() //设置主表表格高度
    },
    onChangecreatedTime(date, dateString) {
      this.queryParam.createdTime = dateString
    },
    onChangeupdatedTime(date, dateString) {
      this.queryParam.updatedTime = dateString
    },
    handleOk () {
    this.$refs.table.refresh()
    },
    onSelectChange (selectedRowKeys, selectedRows) {
    this.selectedRowKeys = selectedRowKeys
    this.selectedRows = selectedRows
    }
    }
    }
</script>
<style lang="less">
  .table-operator {
    margin-bottom: 18px;
  }
  button {
    margin-right: 8px;
  }
</style>
iWare_RawMaterialWarehouse_Web/src/views/main/WmsBase/WmsMaterial/tabForm.vue
@@ -17,7 +17,7 @@
          Content of Tab Pane 2
        </a-tab-pane>
        <a-tab-pane key="3" tab="批次属性">
          Content of Tab Pane 3
          éœ€æ±‚待定
        </a-tab-pane>
        <a-tab-pane key="4" tab="替代品管理">
          <add-form-sub ref="addFormWmsSubstituteGood" @ok="handleOk" />
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/Dto/WmsControlRuleInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,166 @@
using Admin.NET.Core;
using Admin.NET.Core.Service;
using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application
{
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则查询参数
    /// </summary>
    public class WmsControlRuleSearch : PageInputBase
    {
        /// <summary>
        /// è§„则编号
        /// </summary>
        public virtual string RuleCode { get; set; }
        /// <summary>
        /// è§„则名称
        /// </summary>
        public virtual string RuleName { get; set; }
        /// <summary>
        /// è§„则描述
        /// </summary>
        public virtual string RuleDesc { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        public virtual bool? IsDisabled { get; set; }
        /// <summary>
        /// åˆ›å»ºæ—¶é—´
        /// </summary>
        public virtual List<string> CreatedTime { get; set; }
        /// <summary>
        /// æ›´æ–°æ—¶é—´
        /// </summary>
        public virtual List<string> UpdatedTime { get; set; }
        /// <summary>
        /// åˆ›å»ºè€…名称
        /// </summary>
        public virtual string CreatedUserName { get; set; }
        /// <summary>
        /// ä¿®æ”¹è€…名称
        /// </summary>
        public virtual string UpdatedUserName { get; set; }
    }
        /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则不分页查询参数
    /// </summary>
    public class WmsControlRuleSearchNonPage : PageInputNonPageBase
    {
        /// <summary>
        /// è§„则编号
        /// </summary>
        public virtual string RuleCode { get; set; }
        /// <summary>
        /// è§„则名称
        /// </summary>
        public virtual string RuleName { get; set; }
        /// <summary>
        /// è§„则描述
        /// </summary>
        public virtual string RuleDesc { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        public virtual bool? IsDisabled { get; set; }
        /// <summary>
        /// åˆ›å»ºæ—¶é—´
        /// </summary>
         public virtual List<DateTimeOffset>? CreatedTime { get; set; }
        /// <summary>
        /// æ›´æ–°æ—¶é—´
        /// </summary>
         public virtual List<DateTimeOffset>? UpdatedTime { get; set; }
        /// <summary>
        /// åˆ›å»ºè€…名称
        /// </summary>
        public virtual string CreatedUserName { get; set; }
        /// <summary>
        /// ä¿®æ”¹è€…名称
        /// </summary>
        public virtual string UpdatedUserName { get; set; }
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则输入参数
    /// </summary>
    public class WmsControlRuleInput
    {
        /// <summary>
        /// è§„则编号
        /// </summary>
        [Required(ErrorMessage = "规则编号不能为空")]
        public virtual string RuleCode { get; set; }
        /// <summary>
        /// è§„则名称
        /// </summary>
        [Required(ErrorMessage = "规则名称不能为空")]
        public virtual string RuleName { get; set; }
        /// <summary>
        /// è§„则描述
        /// </summary>
        public virtual string RuleDesc { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        [Required(ErrorMessage = "是否禁用不能为空")]
        public virtual bool IsDisabled { get; set; }
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则新增参数
    /// </summary>
    public class AddWmsControlRuleInput : WmsControlRuleInput
    {
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则删除参数
    /// </summary>
    public class DeleteWmsControlRuleInput : BaseId
    {
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则更新参数
    /// </summary>
    public class UpdateWmsControlRuleInput : WmsControlRuleInput
    {
        /// <summary>
        /// Id主键
        /// </summary>
        [Required(ErrorMessage = "Id主键不能为空")]
        public long? Id { get; set; }
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则获取单个参数
    /// </summary>
    public class QueryeWmsControlRuleInput : BaseId
    {
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/Dto/WmsControlRuleOutput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,57 @@
using Admin.NET.Core.Util.LowCode.Dto;
using System;
namespace Admin.NET.Application
{
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则输出参数
    /// </summary>
    public class WmsControlRuleOutput
    {
        /// <summary>
        /// è§„则编号
        /// </summary>
        public string RuleCode { get; set; }
        /// <summary>
        /// è§„则名称
        /// </summary>
        public string RuleName { get; set; }
        /// <summary>
        /// è§„则描述
        /// </summary>
        public string RuleDesc { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        public bool IsDisabled { get; set; }
        /// <summary>
        /// Id主键
        /// </summary>
        public long? Id { get; set; }
        /// <summary>
        /// åˆ›å»ºæ—¶é—´
        /// </summary>
        public DateTimeOffset? CreatedTime { get; set; }
        /// <summary>
        /// æ›´æ–°æ—¶é—´
        /// </summary>
        public DateTimeOffset? UpdatedTime { get; set; }
        /// <summary>
        /// åˆ›å»ºè€…名称
        /// </summary>
        public string CreatedUserName { get; set; }
        /// <summary>
        /// ä¿®æ”¹è€…名称
        /// </summary>
        public string UpdatedUserName { get; set; }
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/IWmsControlRuleService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
using Admin.NET.Core;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Admin.NET.Application
{
    public interface IWmsControlRuleService
    {
        Task<WmsControlRuleOutput> Get([FromQuery] QueryeWmsControlRuleInput input);
        Task<List<WmsControlRuleOutput>> List([FromQuery] WmsControlRuleInput input);
        Task<PageResult<WmsControlRuleOutput>> Page([FromQuery] WmsControlRuleSearch input);
        Task<List<WmsControlRuleOutput>> ListNonPageAsync([FromQuery] WmsControlRuleSearchNonPage input);
        Task Add(AddWmsControlRuleInput input);
        Task Update(UpdateWmsControlRuleInput input);
        Task Delete(DeleteWmsControlRuleInput input);
        Task<int> ImportExcelAsync(IFormFile file);
        IActionResult DownloadExcelTemplate(string version);
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/Map/WmsControlRuleMapper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
using Mapster;
using Admin.NET.Core;
namespace Admin.NET.Application
{
    public class WmsControlRuleMapper : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<AddWmsControlRuleInput, WmsControlRule>()
            ;
            config.ForType<UpdateWmsControlRuleInput, WmsControlRule>()
            ;
            config.ForType<WmsControlRule, WmsControlRuleOutput>()
            ;
        }
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRule/WmsControlRuleService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,418 @@
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Admin.NET.Core;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using Microsoft.AspNetCore.Http;
using System.Text;
using System.Web;
using System.ComponentModel;
using System.Data;
namespace Admin.NET.Application
{
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则服务
    /// </summary>
    [ApiDescriptionSettings("WmsBase", Name = "WmsControlRule", Order = 100)]
    [Route("api")]
    public class WmsControlRuleService : IWmsControlRuleService, IDynamicApiController, ITransient
    {
        private readonly IRepository<WmsControlRule,MasterDbContextLocator> _wmsControlRuleRep;
        private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep;
        private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep;
        private readonly ISysExcelTemplateService _sysExcelTemplateService;
        private readonly static object _lock = new();
        public WmsControlRuleService(
            IRepository<WmsControlRule,MasterDbContextLocator> wmsControlRuleRep
            ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep
            ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep
            ,ISysExcelTemplateService sysExcelTemplateService
        )
        {
            _wmsControlRuleRep = wmsControlRuleRep;
         _sysDictTypeRep = sysDictTypeRep;
         _sysDictDataRep = sysDictDataRep;
         _sysExcelTemplateService = sysExcelTemplateService;
        }
        /// <summary>
        /// åˆ†é¡µæŸ¥è¯¢æŽ§åˆ¶å±žæ€§è§„则
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("WmsControlRule/page")]
        public async Task<PageResult<WmsControlRuleOutput>> Page([FromQuery] WmsControlRuleSearch input)
        {
            var wmsControlRules = await _wmsControlRuleRep.DetachedEntities
                                     .Where(!string.IsNullOrEmpty(input.RuleCode), u => u.RuleCode == input.RuleCode)
                                     .Where(!string.IsNullOrEmpty(input.RuleName), u => u.RuleName == input.RuleName)
                                     .Where(!string.IsNullOrEmpty(input.RuleDesc), u => u.RuleDesc == input.RuleDesc)
                                     .Where(input.IsDisabled != null, u => u.IsDisabled == input.IsDisabled)
                                     .Where(input.CreatedTime!=null, u => u.CreatedTime>=  Convert.ToDateTime(input.CreatedTime[0]) && u.CreatedTime<= Convert.ToDateTime(input.CreatedTime[1]))
                                     .Where(input.UpdatedTime!=null, u => u.UpdatedTime>=  Convert.ToDateTime(input.UpdatedTime[0]) && u.UpdatedTime<= Convert.ToDateTime(input.UpdatedTime[1]))
                                     .Where(!string.IsNullOrEmpty(input.CreatedUserName), u => u.CreatedUserName == input.CreatedUserName)
                                     .Where(!string.IsNullOrEmpty(input.UpdatedUserName), u => u.UpdatedUserName == input.UpdatedUserName)
                                     .OrderBy(PageInputOrder.OrderBuilder<WmsControlRuleSearch>(input))
                                     .ProjectToType<WmsControlRuleOutput>()
                                     .ToADPagedListAsync(input.PageNo, input.PageSize);
            return wmsControlRules;
        }
        /// <summary>
        /// ä¸åˆ†é¡µæŸ¥è¯¢æŽ§åˆ¶å±žæ€§è§„则列表
        /// </summary>
        /// <param name="input">控制属性规则查询参数</param>
        /// <returns>(控制属性规则)实例列表</returns>
        [HttpGet("WmsControlRule/listNonPage")]
        public async Task<List<WmsControlRuleOutput>> ListNonPageAsync([FromQuery] WmsControlRuleSearchNonPage input)
        {
            var pRuleCode = input.RuleCode?.Trim() ?? "";
            var pRuleName = input.RuleName?.Trim() ?? "";
            var pRuleDesc = input.RuleDesc?.Trim() ?? "";
            var pIsDisabled = input.IsDisabled;
            var pCreatedTime = input.CreatedTime;
            var pUpdatedTime = input.UpdatedTime;
            var pCreatedUserName = input.CreatedUserName?.Trim() ?? "";
            var pUpdatedUserName = input.UpdatedUserName?.Trim() ?? "";
            var wmsControlRules = await _wmsControlRuleRep.DetachedEntities
                .Where(!string.IsNullOrEmpty(pRuleCode), u => u.RuleCode == pRuleCode)
                .Where(!string.IsNullOrEmpty(pRuleName), u => u.RuleName == pRuleName)
                .Where(!string.IsNullOrEmpty(pRuleDesc), u => u.RuleDesc == pRuleDesc)
                .Where(pIsDisabled != null, u => u.IsDisabled == pIsDisabled)
           .Where(input.CreatedTime!=null, u => u.CreatedTime>=  Convert.ToDateTime(input.CreatedTime[0]) && u.CreatedTime<= Convert.ToDateTime(input.CreatedTime[1]))
           .Where(input.UpdatedTime!=null, u => u.UpdatedTime>=  Convert.ToDateTime(input.UpdatedTime[0]) && u.UpdatedTime<= Convert.ToDateTime(input.UpdatedTime[1]))
                .Where(!string.IsNullOrEmpty(pCreatedUserName), u => u.CreatedUserName == pCreatedUserName)
                .Where(!string.IsNullOrEmpty(pUpdatedUserName), u => u.UpdatedUserName == pUpdatedUserName)
            .OrderBy(PageInputOrder.OrderNonPageBuilder(input))
            .ProjectToType<WmsControlRuleOutput>()
            .ToListAsync();
            return wmsControlRules;
        }
         /// <summary>
        /// èŽ·å–æŽ§åˆ¶å±žæ€§è§„åˆ™
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("WmsControlRule/detail")]
        public async Task<WmsControlRuleOutput> Get([FromQuery] QueryeWmsControlRuleInput input)
        {
            return (await _wmsControlRuleRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<WmsControlRuleOutput>();
        }
        /// <summary>
        /// èŽ·å–æŽ§åˆ¶å±žæ€§è§„åˆ™åˆ—è¡¨
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("WmsControlRule/list")]
        public async Task<List<WmsControlRuleOutput>> List([FromQuery] WmsControlRuleInput input)
        {
            return await _wmsControlRuleRep.DetachedEntities.ProjectToType<WmsControlRuleOutput>().ToListAsync();
        }
        #region å¢žã€åˆ ã€æ”¹
        /// <summary>
        /// å¢žåŠ æŽ§åˆ¶å±žæ€§è§„åˆ™
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("WmsControlRule/add")]
        public async Task Add(AddWmsControlRuleInput input)
        {
            var wmsControlRule = input.Adapt<WmsControlRule>();
                        //验证
            await CheckExisit(wmsControlRule);
            wmsControlRule.CreatedUserId = wmsControlRule.UpdatedUserId = SysHelper.GetUserId();
            wmsControlRule.CreatedUserName = wmsControlRule.UpdatedUserName = SysHelper.GetUserName();
            wmsControlRule.CreatedTime = wmsControlRule.UpdatedTime = SysHelper.GetNowTime();
            await _wmsControlRuleRep.InsertAsync(wmsControlRule);
        }
        /// <summary>
        /// åˆ é™¤æŽ§åˆ¶å±žæ€§è§„则
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("WmsControlRule/delete")]
        public async Task Delete(DeleteWmsControlRuleInput input)
        {
            var wmsControlRule = await _wmsControlRuleRep.FirstOrDefaultAsync(u => u.Id == input.Id);
            await _wmsControlRuleRep.DeleteAsync(wmsControlRule);
        }
        /// <summary>
        /// æ›´æ–°æŽ§åˆ¶å±žæ€§è§„则
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("WmsControlRule/edit")]
        public async Task Update(UpdateWmsControlRuleInput input)
        {
            var isExist = await _wmsControlRuleRep.AnyAsync(u => u.Id == input.Id, false);
            if (!isExist) throw Oops.Oh(ErrorCode.D1002);
            var wmsControlRule = input.Adapt<WmsControlRule>();
            //验证
            await CheckExisit(wmsControlRule,true);
            wmsControlRule.UpdatedUserId = SysHelper.GetUserId();
            wmsControlRule.UpdatedUserName = SysHelper.GetUserName();
            wmsControlRule.UpdatedTime = SysHelper.GetNowTime();
            await _wmsControlRuleRep.UpdateAsync(wmsControlRule,ignoreNullValues:true);
        }
        #endregion
        #region å¯¼å…¥
        /// <summary>
        /// Excel模板导入控制属性规则功能
        /// </summary>
        /// <param name="file">Excel模板文件</param>
        /// <returns>导入的记录数</returns>
        [HttpPost("WmsControlRule/importExcel")]
        public async Task<int> ImportExcelAsync(IFormFile file)
        {
            int _HeadStartLine = 2;//第1行是说明,第2行是列名
            int _DataStartLine = 3;//第3行开始是数据
            DataTable importDataTable = ExcelUtil.ImportExcelToDataTable(file, _HeadStartLine, _DataStartLine);
            var addList =await CommonImport(importDataTable, _DataStartLine);
            lock (_lock)
            {
                _wmsControlRuleRep.InsertAsync(addList);
            }
            await Task.CompletedTask;
            return addList.Count;
        }
        /// <summary>
        ///  DataTable转换实体对象列表
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="dataStartLine">模版列名开始行</param>
        /// <returns></returns>
        private async Task<List<WmsControlRule>> CommonImport(DataTable dataTable, int dataStartLine)
        {
            var details = new List<WmsControlRule>();
            int index = dataStartLine;//模版列名开始行
            foreach (System.Data.DataRow row in dataTable.Rows)
            {
                index++;
               //导入模版定制化代码(替换模版使用)
                           var addItem = new WmsControlRule()
                            {
                               CreatedTime = SysHelper.GetNowTime(),
                               CreatedUserId = SysHelper.GetUserId(),
                               CreatedUserName = SysHelper.GetUserName(),
                               UpdatedTime = SysHelper.GetNowTime(),
                               UpdatedUserId = SysHelper.GetUserId(),
                               UpdatedUserName = SysHelper.GetUserName()
                             };
                          #region å®šä¹‰å˜é‡
                           var _RuleCode = "";//规则编号
                           var _RuleName = "";//规则名称
                           var _RuleDesc = "";//规则描述
                           var _IsDisabled = "";//是否禁用
                           var _Id = "";//Id主键
                          #endregion
                          #region å–值
                           _RuleCode = row["规则编号"]?.ToString() ;
                           _RuleName = row["规则名称"]?.ToString() ;
                           _RuleDesc = row["规则描述"]?.ToString() ;
                           _IsDisabled = row["是否禁用"]?.ToString() ;
                           _Id = row["Id主键"]?.ToString() ;
                          #endregion
                          #region éªŒè¯
                          if (string.IsNullOrEmpty(_RuleCode))
                          {
                            throw Oops.Oh($"第{index}行[规则编号]{_RuleCode}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_RuleCode))
                          {
                                addItem.RuleCode = (string)_RuleCode;
                           }
                          if (string.IsNullOrEmpty(_RuleName))
                          {
                            throw Oops.Oh($"第{index}行[规则名称]{_RuleName}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_RuleName))
                          {
                                addItem.RuleName = (string)_RuleName;
                           }
                          if(!string.IsNullOrEmpty(_RuleDesc))
                          {
                                addItem.RuleDesc = (string)_RuleDesc;
                           }
                          if (string.IsNullOrEmpty(_IsDisabled))
                          {
                            throw Oops.Oh($"第{index}行[是否禁用]{_IsDisabled}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_IsDisabled))
                          {
                            if(!_IsDisabled.Equals("是") && !_IsDisabled.Equals("否"))
                             {
                               throw Oops.Oh($"第{index}行[是否禁用]{_IsDisabled}值不正确!");
                             }
                             else
                             {
                               bool outIsDisabled = _IsDisabled.Equals("是") ? true : false;
                               addItem.IsDisabled = outIsDisabled;
                             }
                             }
                          if(!string.IsNullOrEmpty(_Id))
                          {
                              if (!long.TryParse(_Id, out long outId)&&!string.IsNullOrEmpty(_Id))
                              {
                                 throw Oops.Oh($"第{index}行[Id主键]{_Id}值不正确!");
                              }
                              if (outId <= 0&&!string.IsNullOrEmpty(_Id))
                              {
                                 throw Oops.Oh($"第{index}行[Id主键]{_Id}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.Id = outId;
                              }
                          }
                          #endregion
                details.Add(addItem);
            }
              //验重
              await CheckExisitForImport(details);
            return details;
        }
        /// <summary>
        /// æ ¹æ®ç‰ˆæœ¬ä¸‹è½½æŽ§åˆ¶å±žæ€§è§„则的Excel导入模板
        /// </summary>
        /// <param name="version">模板版本</param>
        /// <returns>下载的模板文件</returns>
        [HttpGet("WmsControlRule/downloadExcelTemplate")]
        public IActionResult DownloadExcelTemplate([FromQuery] string version)
        {
            string _path = TemplateConst.EXCEL_TEMPLATEFILE_导入模版路径 + $"\\WmsControlRule{TemplateConst.EXCEL_TEMPLATEFILE_导入模版名称后缀}.xlsx";
            var fileName = HttpUtility.UrlEncode($"导入模板(控制属性规则).xlsx", Encoding.GetEncoding("UTF-8"));
            return new FileStreamResult(new FileStream(_path, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
        }
        #endregion
        #region ç§æœ‰æ–¹æ³•
        /// <summary>
        /// æ ¹æ®è”合主键验证数据是否已存在-数据库
        /// </summary>
        /// <param name="input"></param>
        /// <param name="isEdit"></param>
        /// <returns></returns>
        private async Task CheckExisit( WmsControlRule input,bool isEdit=false)
        {
           bool isExist = false;
           if (!isEdit)//新增
           {
                   //数据是否存在重复
                   isExist = await _wmsControlRuleRep.AnyAsync(u =>
                                   u.RuleCode.Equals(input.RuleCode)
                   ,false);
          }
           else//编辑
          {
                 //当前编辑数据以外是否存在重复
                  isExist = await _wmsControlRuleRep.AnyAsync(u =>
                                    u.Id != input.Id
                                    &&u.RuleCode.Equals(input.RuleCode)
                    ,false);
               }
            if (isExist) throw Oops.Oh(ErrorCode.E0001);
       }
        /// <summary>
        /// æ ¹æ®è”合主键验证数据是否已存在-导入时验证
        /// </summary>
        /// <param name="inputs"></param>
        /// <returns></returns>
        private async Task CheckExisitForImport(List<WmsControlRule> inputs)
        {
            //根据联合主键验证表格中中是否已存在相同数据
                 if (inputs?.Count <= 0)
                 {
                     throw Oops.Oh($"导入数据不能为空");
                 }
                 //数据是否重复
                 var existExcelItem = inputs.GroupBy(g => new {
                                               g.RuleCode
                                               })
                                               .Where(g => g.Count() > 1)
                                               .Select(s => new {
                                               s.Key.RuleCode
                                               }).FirstOrDefault();
                 if (existExcelItem != null)
                 {
                   var wmsControlRule = existExcelItem.Adapt<WmsControlRule>();
                   var item= existExcelItem.Adapt<WmsControlRule>();
                   throw Oops.Oh($"导入的表格中,规则编号[{item.RuleCode}]已存在");
                 }
    //根据联合主键验证数据库中是否已存在相同数据
                 var existDBItem = await _wmsControlRuleRep.DetachedEntities.FirstOrDefaultAsync(w=>
                                                                         inputs.Select(s=>""
                                                                           +s.RuleCode
                                                                        )
                                                                        .Contains(""
                                                                         +w.RuleCode
                  ));
                  if (existDBItem != null)
                 {
                   var wmsControlRule = existExcelItem.Adapt<WmsControlRule>();
                   var item= existExcelItem.Adapt<WmsControlRule>();
                   throw Oops.Oh($"系统中,规则编号[{item.RuleCode}]已存在");
                 }
        }
        #endregion
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/Dto/WmsControlRuleDetailInput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,247 @@
using Admin.NET.Core;
using Admin.NET.Core.Service;
using System.ComponentModel.DataAnnotations;
namespace Admin.NET.Application
{
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细查询参数
    /// </summary>
    public class WmsControlRuleDetailSearch : PageInputBase
    {
        /// <summary>
        /// æŽ§åˆ¶å±žæ€§è§„则ID
        /// </summary>
        public virtual long? ControlRuleId { get; set; }
        /// <summary>
        /// æœ€é«˜åº“å­˜
        /// </summary>
        public virtual decimal? MaxImumqty { get; set; }
        /// <summary>
        /// æœ€ä½Žåº“å­˜
        /// </summary>
        public virtual decimal? MinImumqty { get; set; }
        /// <summary>
        /// å®‰å…¨åº“å­˜
        /// </summary>
        public virtual decimal? SafeImumqty { get; set; }
        /// <summary>
        /// æœ€å°åº“龄
        /// </summary>
        public virtual decimal? MinStorageAge { get; set; }
        /// <summary>
        /// æœ€å¤§åº“龄
        /// </summary>
        public virtual decimal? MaxStorageAge { get; set; }
        /// <summary>
        /// æ˜¯å¦å…æ£€
        /// </summary>
        public virtual bool? IsNotChek { get; set; }
        /// <summary>
        /// ä¿è´¨æœŸå¤©æ•°
        /// </summary>
        public virtual decimal? ShelfLifeDays { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        public virtual bool? IsDisabled { get; set; }
        /// <summary>
        /// åˆ›å»ºæ—¶é—´
        /// </summary>
        public virtual List<string> CreatedTime { get; set; }
        /// <summary>
        /// æ›´æ–°æ—¶é—´
        /// </summary>
        public virtual List<string> UpdatedTime { get; set; }
        /// <summary>
        /// åˆ›å»ºè€…名称
        /// </summary>
        public virtual string CreatedUserName { get; set; }
        /// <summary>
        /// ä¿®æ”¹è€…名称
        /// </summary>
        public virtual string UpdatedUserName { get; set; }
    }
        /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细不分页查询参数
    /// </summary>
    public class WmsControlRuleDetailSearchNonPage : PageInputNonPageBase
    {
        /// <summary>
        /// æŽ§åˆ¶å±žæ€§è§„则ID
        /// </summary>
        public virtual long? ControlRuleId { get; set; }
        /// <summary>
        /// æœ€é«˜åº“å­˜
        /// </summary>
        public virtual decimal? MaxImumqty { get; set; }
        /// <summary>
        /// æœ€ä½Žåº“å­˜
        /// </summary>
        public virtual decimal? MinImumqty { get; set; }
        /// <summary>
        /// å®‰å…¨åº“å­˜
        /// </summary>
        public virtual decimal? SafeImumqty { get; set; }
        /// <summary>
        /// æœ€å°åº“龄
        /// </summary>
        public virtual decimal? MinStorageAge { get; set; }
        /// <summary>
        /// æœ€å¤§åº“龄
        /// </summary>
        public virtual decimal? MaxStorageAge { get; set; }
        /// <summary>
        /// æ˜¯å¦å…æ£€
        /// </summary>
        public virtual bool? IsNotChek { get; set; }
        /// <summary>
        /// ä¿è´¨æœŸå¤©æ•°
        /// </summary>
        public virtual decimal? ShelfLifeDays { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        public virtual bool? IsDisabled { get; set; }
        /// <summary>
        /// åˆ›å»ºæ—¶é—´
        /// </summary>
         public virtual List<DateTimeOffset>? CreatedTime { get; set; }
        /// <summary>
        /// æ›´æ–°æ—¶é—´
        /// </summary>
         public virtual List<DateTimeOffset>? UpdatedTime { get; set; }
        /// <summary>
        /// åˆ›å»ºè€…名称
        /// </summary>
        public virtual string CreatedUserName { get; set; }
        /// <summary>
        /// ä¿®æ”¹è€…名称
        /// </summary>
        public virtual string UpdatedUserName { get; set; }
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细输入参数
    /// </summary>
    public class WmsControlRuleDetailInput
    {
        /// <summary>
        /// æŽ§åˆ¶å±žæ€§è§„则ID
        /// </summary>
        [Required(ErrorMessage = "控制属性规则ID不能为空")]
        public virtual long ControlRuleId { get; set; }
        /// <summary>
        /// æœ€é«˜åº“å­˜
        /// </summary>
        [Required(ErrorMessage = "最高库存不能为空")]
        public virtual decimal MaxImumqty { get; set; }
        /// <summary>
        /// æœ€ä½Žåº“å­˜
        /// </summary>
        [Required(ErrorMessage = "最低库存不能为空")]
        public virtual decimal MinImumqty { get; set; }
        /// <summary>
        /// å®‰å…¨åº“å­˜
        /// </summary>
        [Required(ErrorMessage = "安全库存不能为空")]
        public virtual decimal SafeImumqty { get; set; }
        /// <summary>
        /// æœ€å°åº“龄
        /// </summary>
        [Required(ErrorMessage = "最小库龄不能为空")]
        public virtual decimal MinStorageAge { get; set; }
        /// <summary>
        /// æœ€å¤§åº“龄
        /// </summary>
        [Required(ErrorMessage = "最大库龄不能为空")]
        public virtual decimal MaxStorageAge { get; set; }
        /// <summary>
        /// æ˜¯å¦å…æ£€
        /// </summary>
        [Required(ErrorMessage = "是否免检不能为空")]
        public virtual bool IsNotChek { get; set; }
        /// <summary>
        /// ä¿è´¨æœŸå¤©æ•°
        /// </summary>
        [Required(ErrorMessage = "保质期天数不能为空")]
        public virtual decimal ShelfLifeDays { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        [Required(ErrorMessage = "是否禁用不能为空")]
        public virtual bool IsDisabled { get; set; }
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细新增参数
    /// </summary>
    public class AddWmsControlRuleDetailInput : WmsControlRuleDetailInput
    {
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细删除参数
    /// </summary>
    public class DeleteWmsControlRuleDetailInput : BaseId
    {
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细更新参数
    /// </summary>
    public class UpdateWmsControlRuleDetailInput : WmsControlRuleDetailInput
    {
        /// <summary>
        /// Id主键
        /// </summary>
        [Required(ErrorMessage = "Id主键不能为空")]
        public long? Id { get; set; }
    }
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细获取单个参数
    /// </summary>
    public class QueryeWmsControlRuleDetailInput : BaseId
    {
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/Dto/WmsControlRuleDetailOutput.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,82 @@
using Admin.NET.Core.Util.LowCode.Dto;
using System;
namespace Admin.NET.Application
{
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细输出参数
    /// </summary>
    public class WmsControlRuleDetailOutput
    {
        /// <summary>
        /// æŽ§åˆ¶å±žæ€§è§„则ID
        /// </summary>
        public long ControlRuleId { get; set; }
        /// <summary>
        /// æœ€é«˜åº“å­˜
        /// </summary>
        public decimal MaxImumqty { get; set; }
        /// <summary>
        /// æœ€ä½Žåº“å­˜
        /// </summary>
        public decimal MinImumqty { get; set; }
        /// <summary>
        /// å®‰å…¨åº“å­˜
        /// </summary>
        public decimal SafeImumqty { get; set; }
        /// <summary>
        /// æœ€å°åº“龄
        /// </summary>
        public decimal MinStorageAge { get; set; }
        /// <summary>
        /// æœ€å¤§åº“龄
        /// </summary>
        public decimal MaxStorageAge { get; set; }
        /// <summary>
        /// æ˜¯å¦å…æ£€
        /// </summary>
        public bool IsNotChek { get; set; }
        /// <summary>
        /// ä¿è´¨æœŸå¤©æ•°
        /// </summary>
        public decimal ShelfLifeDays { get; set; }
        /// <summary>
        /// æ˜¯å¦ç¦ç”¨
        /// </summary>
        public bool IsDisabled { get; set; }
        /// <summary>
        /// Id主键
        /// </summary>
        public long? Id { get; set; }
        /// <summary>
        /// åˆ›å»ºæ—¶é—´
        /// </summary>
        public DateTimeOffset? CreatedTime { get; set; }
        /// <summary>
        /// æ›´æ–°æ—¶é—´
        /// </summary>
        public DateTimeOffset? UpdatedTime { get; set; }
        /// <summary>
        /// åˆ›å»ºè€…名称
        /// </summary>
        public string CreatedUserName { get; set; }
        /// <summary>
        /// ä¿®æ”¹è€…名称
        /// </summary>
        public string UpdatedUserName { get; set; }
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/IWmsControlRuleDetailService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,22 @@
using Admin.NET.Core;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Admin.NET.Application
{
    public interface IWmsControlRuleDetailService
    {
        Task<WmsControlRuleDetailOutput> Get([FromQuery] QueryeWmsControlRuleDetailInput input);
        Task<List<WmsControlRuleDetailOutput>> List([FromQuery] WmsControlRuleDetailInput input);
        Task<PageResult<WmsControlRuleDetailOutput>> Page([FromQuery] WmsControlRuleDetailSearch input);
        Task<List<WmsControlRuleDetailOutput>> ListNonPageAsync([FromQuery] WmsControlRuleDetailSearchNonPage input);
        Task Add(AddWmsControlRuleDetailInput input);
        Task Update(UpdateWmsControlRuleDetailInput input);
        Task Delete(DeleteWmsControlRuleDetailInput input);
        Task<int> ImportExcelAsync(IFormFile file);
        IActionResult DownloadExcelTemplate(string version);
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/Map/WmsControlRuleDetailMapper.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,18 @@
using Mapster;
using Admin.NET.Core;
namespace Admin.NET.Application
{
    public class WmsControlRuleDetailMapper : IRegister
    {
        public void Register(TypeAdapterConfig config)
        {
            config.ForType<AddWmsControlRuleDetailInput, WmsControlRuleDetail>()
            ;
            config.ForType<UpdateWmsControlRuleDetailInput, WmsControlRuleDetail>()
            ;
            config.ForType<WmsControlRuleDetail, WmsControlRuleDetailOutput>()
            ;
        }
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/WmsBase/WmsControlRuleDetail/WmsControlRuleDetailService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,592 @@
using Furion.DatabaseAccessor;
using Furion.DatabaseAccessor.Extensions;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Admin.NET.Core;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Linq.Dynamic.Core;
using Microsoft.AspNetCore.Http;
using System.Text;
using System.Web;
using System.ComponentModel;
using System.Data;
namespace Admin.NET.Application
{
    /// <summary>
    /// æŽ§åˆ¶å±žæ€§è§„则明细服务
    /// </summary>
    [ApiDescriptionSettings("WmsBase", Name = "WmsControlRuleDetail", Order = 100)]
    [Route("api")]
    public class WmsControlRuleDetailService : IWmsControlRuleDetailService, IDynamicApiController, ITransient
    {
        private readonly IRepository<WmsControlRuleDetail,MasterDbContextLocator> _wmsControlRuleDetailRep;
        private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep;
        private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep;
        private readonly ISysExcelTemplateService _sysExcelTemplateService;
        private readonly static object _lock = new();
        public WmsControlRuleDetailService(
            IRepository<WmsControlRuleDetail,MasterDbContextLocator> wmsControlRuleDetailRep
            ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep
            ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep
            ,ISysExcelTemplateService sysExcelTemplateService
        )
        {
            _wmsControlRuleDetailRep = wmsControlRuleDetailRep;
         _sysDictTypeRep = sysDictTypeRep;
         _sysDictDataRep = sysDictDataRep;
         _sysExcelTemplateService = sysExcelTemplateService;
        }
        /// <summary>
        /// åˆ†é¡µæŸ¥è¯¢æŽ§åˆ¶å±žæ€§è§„则明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("WmsControlRuleDetail/page")]
        public async Task<PageResult<WmsControlRuleDetailOutput>> Page([FromQuery] WmsControlRuleDetailSearch input)
        {
            var wmsControlRuleDetails = await _wmsControlRuleDetailRep.DetachedEntities
                                     .Where(input.ControlRuleId != null, u => u.ControlRuleId == input.ControlRuleId)
                                     .Where(input.MaxImumqty != null, u => u.MaxImumqty == input.MaxImumqty)
                                     .Where(input.MinImumqty != null, u => u.MinImumqty == input.MinImumqty)
                                     .Where(input.SafeImumqty != null, u => u.SafeImumqty == input.SafeImumqty)
                                     .Where(input.MinStorageAge != null, u => u.MinStorageAge == input.MinStorageAge)
                                     .Where(input.MaxStorageAge != null, u => u.MaxStorageAge == input.MaxStorageAge)
                                     .Where(input.IsNotChek != null, u => u.IsNotChek == input.IsNotChek)
                                     .Where(input.ShelfLifeDays != null, u => u.ShelfLifeDays == input.ShelfLifeDays)
                                     .Where(input.IsDisabled != null, u => u.IsDisabled == input.IsDisabled)
                                     .Where(input.CreatedTime!=null, u => u.CreatedTime>=  Convert.ToDateTime(input.CreatedTime[0]) && u.CreatedTime<= Convert.ToDateTime(input.CreatedTime[1]))
                                     .Where(input.UpdatedTime!=null, u => u.UpdatedTime>=  Convert.ToDateTime(input.UpdatedTime[0]) && u.UpdatedTime<= Convert.ToDateTime(input.UpdatedTime[1]))
                                     .Where(!string.IsNullOrEmpty(input.CreatedUserName), u => u.CreatedUserName == input.CreatedUserName)
                                     .Where(!string.IsNullOrEmpty(input.UpdatedUserName), u => u.UpdatedUserName == input.UpdatedUserName)
                                     .OrderBy(PageInputOrder.OrderBuilder<WmsControlRuleDetailSearch>(input))
                                     .ProjectToType<WmsControlRuleDetailOutput>()
                                     .ToADPagedListAsync(input.PageNo, input.PageSize);
            return wmsControlRuleDetails;
        }
        /// <summary>
        /// ä¸åˆ†é¡µæŸ¥è¯¢æŽ§åˆ¶å±žæ€§è§„则明细列表
        /// </summary>
        /// <param name="input">控制属性规则明细查询参数</param>
        /// <returns>(控制属性规则明细)实例列表</returns>
        [HttpGet("WmsControlRuleDetail/listNonPage")]
        public async Task<List<WmsControlRuleDetailOutput>> ListNonPageAsync([FromQuery] WmsControlRuleDetailSearchNonPage input)
        {
            var pControlRuleId = input.ControlRuleId;
            var pMaxImumqty = input.MaxImumqty;
            var pMinImumqty = input.MinImumqty;
            var pSafeImumqty = input.SafeImumqty;
            var pMinStorageAge = input.MinStorageAge;
            var pMaxStorageAge = input.MaxStorageAge;
            var pIsNotChek = input.IsNotChek;
            var pShelfLifeDays = input.ShelfLifeDays;
            var pIsDisabled = input.IsDisabled;
            var pCreatedTime = input.CreatedTime;
            var pUpdatedTime = input.UpdatedTime;
            var pCreatedUserName = input.CreatedUserName?.Trim() ?? "";
            var pUpdatedUserName = input.UpdatedUserName?.Trim() ?? "";
            var wmsControlRuleDetails = await _wmsControlRuleDetailRep.DetachedEntities
                .Where(pControlRuleId != null, u => u.ControlRuleId == pControlRuleId)
                .Where(pMaxImumqty != null, u => u.MaxImumqty == pMaxImumqty)
                .Where(pMinImumqty != null, u => u.MinImumqty == pMinImumqty)
                .Where(pSafeImumqty != null, u => u.SafeImumqty == pSafeImumqty)
                .Where(pMinStorageAge != null, u => u.MinStorageAge == pMinStorageAge)
                .Where(pMaxStorageAge != null, u => u.MaxStorageAge == pMaxStorageAge)
                .Where(pIsNotChek != null, u => u.IsNotChek == pIsNotChek)
                .Where(pShelfLifeDays != null, u => u.ShelfLifeDays == pShelfLifeDays)
                .Where(pIsDisabled != null, u => u.IsDisabled == pIsDisabled)
           .Where(input.CreatedTime!=null, u => u.CreatedTime>=  Convert.ToDateTime(input.CreatedTime[0]) && u.CreatedTime<= Convert.ToDateTime(input.CreatedTime[1]))
           .Where(input.UpdatedTime!=null, u => u.UpdatedTime>=  Convert.ToDateTime(input.UpdatedTime[0]) && u.UpdatedTime<= Convert.ToDateTime(input.UpdatedTime[1]))
                .Where(!string.IsNullOrEmpty(pCreatedUserName), u => u.CreatedUserName == pCreatedUserName)
                .Where(!string.IsNullOrEmpty(pUpdatedUserName), u => u.UpdatedUserName == pUpdatedUserName)
            .OrderBy(PageInputOrder.OrderNonPageBuilder(input))
            .ProjectToType<WmsControlRuleDetailOutput>()
            .ToListAsync();
            return wmsControlRuleDetails;
        }
         /// <summary>
        /// èŽ·å–æŽ§åˆ¶å±žæ€§è§„åˆ™æ˜Žç»†
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("WmsControlRuleDetail/detail")]
        public async Task<WmsControlRuleDetailOutput> Get([FromQuery] QueryeWmsControlRuleDetailInput input)
        {
            return (await _wmsControlRuleDetailRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<WmsControlRuleDetailOutput>();
        }
        /// <summary>
        /// èŽ·å–æŽ§åˆ¶å±žæ€§è§„åˆ™æ˜Žç»†åˆ—è¡¨
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet("WmsControlRuleDetail/list")]
        public async Task<List<WmsControlRuleDetailOutput>> List([FromQuery] WmsControlRuleDetailInput input)
        {
            return await _wmsControlRuleDetailRep.DetachedEntities.ProjectToType<WmsControlRuleDetailOutput>().ToListAsync();
        }
        #region å¢žã€åˆ ã€æ”¹
        /// <summary>
        /// å¢žåŠ æŽ§åˆ¶å±žæ€§è§„åˆ™æ˜Žç»†
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("WmsControlRuleDetail/add")]
        public async Task Add(AddWmsControlRuleDetailInput input)
        {
            var wmsControlRuleDetail = input.Adapt<WmsControlRuleDetail>();
                        //验证
            await CheckExisit(wmsControlRuleDetail);
            wmsControlRuleDetail.CreatedUserId = wmsControlRuleDetail.UpdatedUserId = SysHelper.GetUserId();
            wmsControlRuleDetail.CreatedUserName = wmsControlRuleDetail.UpdatedUserName = SysHelper.GetUserName();
            wmsControlRuleDetail.CreatedTime = wmsControlRuleDetail.UpdatedTime = SysHelper.GetNowTime();
            await _wmsControlRuleDetailRep.InsertAsync(wmsControlRuleDetail);
        }
        /// <summary>
        /// åˆ é™¤æŽ§åˆ¶å±žæ€§è§„则明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("WmsControlRuleDetail/delete")]
        public async Task Delete(DeleteWmsControlRuleDetailInput input)
        {
            var wmsControlRuleDetail = await _wmsControlRuleDetailRep.FirstOrDefaultAsync(u => u.Id == input.Id);
            await _wmsControlRuleDetailRep.DeleteAsync(wmsControlRuleDetail);
        }
        /// <summary>
        /// æ›´æ–°æŽ§åˆ¶å±žæ€§è§„则明细
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("WmsControlRuleDetail/edit")]
        public async Task Update(UpdateWmsControlRuleDetailInput input)
        {
            var isExist = await _wmsControlRuleDetailRep.AnyAsync(u => u.Id == input.Id, false);
            if (!isExist) throw Oops.Oh(ErrorCode.D1002);
            var wmsControlRuleDetail = input.Adapt<WmsControlRuleDetail>();
            //验证
            await CheckExisit(wmsControlRuleDetail,true);
            wmsControlRuleDetail.UpdatedUserId = SysHelper.GetUserId();
            wmsControlRuleDetail.UpdatedUserName = SysHelper.GetUserName();
            wmsControlRuleDetail.UpdatedTime = SysHelper.GetNowTime();
            await _wmsControlRuleDetailRep.UpdateAsync(wmsControlRuleDetail,ignoreNullValues:true);
        }
        #endregion
        #region å¯¼å…¥
        /// <summary>
        /// Excel模板导入控制属性规则明细功能
        /// </summary>
        /// <param name="file">Excel模板文件</param>
        /// <returns>导入的记录数</returns>
        [HttpPost("WmsControlRuleDetail/importExcel")]
        public async Task<int> ImportExcelAsync(IFormFile file)
        {
            int _HeadStartLine = 2;//第1行是说明,第2行是列名
            int _DataStartLine = 3;//第3行开始是数据
            DataTable importDataTable = ExcelUtil.ImportExcelToDataTable(file, _HeadStartLine, _DataStartLine);
            var addList =await CommonImport(importDataTable, _DataStartLine);
            lock (_lock)
            {
                _wmsControlRuleDetailRep.InsertAsync(addList);
            }
            await Task.CompletedTask;
            return addList.Count;
        }
        /// <summary>
        ///  DataTable转换实体对象列表
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="dataStartLine">模版列名开始行</param>
        /// <returns></returns>
        private async Task<List<WmsControlRuleDetail>> CommonImport(DataTable dataTable, int dataStartLine)
        {
            var details = new List<WmsControlRuleDetail>();
            int index = dataStartLine;//模版列名开始行
            foreach (System.Data.DataRow row in dataTable.Rows)
            {
                index++;
               //导入模版定制化代码(替换模版使用)
                           var addItem = new WmsControlRuleDetail()
                            {
                               CreatedTime = SysHelper.GetNowTime(),
                               CreatedUserId = SysHelper.GetUserId(),
                               CreatedUserName = SysHelper.GetUserName(),
                               UpdatedTime = SysHelper.GetNowTime(),
                               UpdatedUserId = SysHelper.GetUserId(),
                               UpdatedUserName = SysHelper.GetUserName()
                             };
                          #region å®šä¹‰å˜é‡
                           var _ControlRuleId = "";//控制属性规则ID
                           var _MaxImumqty = "";//最高库存
                           var _MinImumqty = "";//最低库存
                           var _SafeImumqty = "";//安全库存
                           var _MinStorageAge = "";//最小库龄
                           var _MaxStorageAge = "";//最大库龄
                           var _IsNotChek = "";//是否免检
                           var _ShelfLifeDays = "";//保质期天数
                           var _IsDisabled = "";//是否禁用
                           var _Id = "";//Id主键
                          #endregion
                          #region å–值
                           _ControlRuleId = row["控制属性规则ID"]?.ToString() ;
                           _MaxImumqty = row["最高库存"]?.ToString() ;
                           _MinImumqty = row["最低库存"]?.ToString() ;
                           _SafeImumqty = row["安全库存"]?.ToString() ;
                           _MinStorageAge = row["最小库龄"]?.ToString() ;
                           _MaxStorageAge = row["最大库龄"]?.ToString() ;
                           _IsNotChek = row["是否免检"]?.ToString() ;
                           _ShelfLifeDays = row["保质期天数"]?.ToString() ;
                           _IsDisabled = row["是否禁用"]?.ToString() ;
                           _Id = row["Id主键"]?.ToString() ;
                          #endregion
                          #region éªŒè¯
                          if (string.IsNullOrEmpty(_ControlRuleId))
                          {
                            throw Oops.Oh($"第{index}行[控制属性规则ID]{_ControlRuleId}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_ControlRuleId))
                          {
                              if (!long.TryParse(_ControlRuleId, out long outControlRuleId)&&!string.IsNullOrEmpty(_ControlRuleId))
                              {
                                 throw Oops.Oh($"第{index}行[控制属性规则ID]{_ControlRuleId}值不正确!");
                              }
                              if (outControlRuleId <= 0&&!string.IsNullOrEmpty(_ControlRuleId))
                              {
                                 throw Oops.Oh($"第{index}行[控制属性规则ID]{_ControlRuleId}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.ControlRuleId = outControlRuleId;
                              }
                          }
                          if (string.IsNullOrEmpty(_MaxImumqty))
                          {
                            throw Oops.Oh($"第{index}行[最高库存]{_MaxImumqty}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_MaxImumqty))
                          {
                              if (!decimal.TryParse(_MaxImumqty, out decimal outMaxImumqty)&&!string.IsNullOrEmpty(_MaxImumqty))
                              {
                                 throw Oops.Oh($"第{index}行[最高库存]{_MaxImumqty}值不正确!");
                              }
                              if (outMaxImumqty <= 0&&!string.IsNullOrEmpty(_MaxImumqty))
                              {
                                 throw Oops.Oh($"第{index}行[最高库存]{_MaxImumqty}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.MaxImumqty = outMaxImumqty;
                              }
                          }
                          if (string.IsNullOrEmpty(_MinImumqty))
                          {
                            throw Oops.Oh($"第{index}行[最低库存]{_MinImumqty}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_MinImumqty))
                          {
                              if (!decimal.TryParse(_MinImumqty, out decimal outMinImumqty)&&!string.IsNullOrEmpty(_MinImumqty))
                              {
                                 throw Oops.Oh($"第{index}行[最低库存]{_MinImumqty}值不正确!");
                              }
                              if (outMinImumqty <= 0&&!string.IsNullOrEmpty(_MinImumqty))
                              {
                                 throw Oops.Oh($"第{index}行[最低库存]{_MinImumqty}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.MinImumqty = outMinImumqty;
                              }
                          }
                          if (string.IsNullOrEmpty(_SafeImumqty))
                          {
                            throw Oops.Oh($"第{index}行[安全库存]{_SafeImumqty}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_SafeImumqty))
                          {
                              if (!decimal.TryParse(_SafeImumqty, out decimal outSafeImumqty)&&!string.IsNullOrEmpty(_SafeImumqty))
                              {
                                 throw Oops.Oh($"第{index}行[安全库存]{_SafeImumqty}值不正确!");
                              }
                              if (outSafeImumqty <= 0&&!string.IsNullOrEmpty(_SafeImumqty))
                              {
                                 throw Oops.Oh($"第{index}行[安全库存]{_SafeImumqty}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.SafeImumqty = outSafeImumqty;
                              }
                          }
                          if (string.IsNullOrEmpty(_MinStorageAge))
                          {
                            throw Oops.Oh($"第{index}行[最小库龄]{_MinStorageAge}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_MinStorageAge))
                          {
                              if (!decimal.TryParse(_MinStorageAge, out decimal outMinStorageAge)&&!string.IsNullOrEmpty(_MinStorageAge))
                              {
                                 throw Oops.Oh($"第{index}行[最小库龄]{_MinStorageAge}值不正确!");
                              }
                              if (outMinStorageAge <= 0&&!string.IsNullOrEmpty(_MinStorageAge))
                              {
                                 throw Oops.Oh($"第{index}行[最小库龄]{_MinStorageAge}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.MinStorageAge = outMinStorageAge;
                              }
                          }
                          if (string.IsNullOrEmpty(_MaxStorageAge))
                          {
                            throw Oops.Oh($"第{index}行[最大库龄]{_MaxStorageAge}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_MaxStorageAge))
                          {
                              if (!decimal.TryParse(_MaxStorageAge, out decimal outMaxStorageAge)&&!string.IsNullOrEmpty(_MaxStorageAge))
                              {
                                 throw Oops.Oh($"第{index}行[最大库龄]{_MaxStorageAge}值不正确!");
                              }
                              if (outMaxStorageAge <= 0&&!string.IsNullOrEmpty(_MaxStorageAge))
                              {
                                 throw Oops.Oh($"第{index}行[最大库龄]{_MaxStorageAge}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.MaxStorageAge = outMaxStorageAge;
                              }
                          }
                          if (string.IsNullOrEmpty(_IsNotChek))
                          {
                            throw Oops.Oh($"第{index}行[是否免检]{_IsNotChek}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_IsNotChek))
                          {
                            if(!_IsNotChek.Equals("是") && !_IsNotChek.Equals("否"))
                             {
                               throw Oops.Oh($"第{index}行[是否免检]{_IsNotChek}值不正确!");
                             }
                             else
                             {
                               bool outIsNotChek = _IsNotChek.Equals("是") ? true : false;
                               addItem.IsNotChek = outIsNotChek;
                             }
                             }
                          if (string.IsNullOrEmpty(_ShelfLifeDays))
                          {
                            throw Oops.Oh($"第{index}行[保质期天数]{_ShelfLifeDays}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_ShelfLifeDays))
                          {
                              if (!decimal.TryParse(_ShelfLifeDays, out decimal outShelfLifeDays)&&!string.IsNullOrEmpty(_ShelfLifeDays))
                              {
                                 throw Oops.Oh($"第{index}行[保质期天数]{_ShelfLifeDays}值不正确!");
                              }
                              if (outShelfLifeDays <= 0&&!string.IsNullOrEmpty(_ShelfLifeDays))
                              {
                                 throw Oops.Oh($"第{index}行[保质期天数]{_ShelfLifeDays}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.ShelfLifeDays = outShelfLifeDays;
                              }
                          }
                          if (string.IsNullOrEmpty(_IsDisabled))
                          {
                            throw Oops.Oh($"第{index}行[是否禁用]{_IsDisabled}不能为空!");
                          }
                          if(!string.IsNullOrEmpty(_IsDisabled))
                          {
                            if(!_IsDisabled.Equals("是") && !_IsDisabled.Equals("否"))
                             {
                               throw Oops.Oh($"第{index}行[是否禁用]{_IsDisabled}值不正确!");
                             }
                             else
                             {
                               bool outIsDisabled = _IsDisabled.Equals("是") ? true : false;
                               addItem.IsDisabled = outIsDisabled;
                             }
                             }
                          if(!string.IsNullOrEmpty(_Id))
                          {
                              if (!long.TryParse(_Id, out long outId)&&!string.IsNullOrEmpty(_Id))
                              {
                                 throw Oops.Oh($"第{index}行[Id主键]{_Id}值不正确!");
                              }
                              if (outId <= 0&&!string.IsNullOrEmpty(_Id))
                              {
                                 throw Oops.Oh($"第{index}行[Id主键]{_Id}值不能小于等于0!");
                              }
                              else
                              {
                                 addItem.Id = outId;
                              }
                          }
                          #endregion
                details.Add(addItem);
            }
              //验重
              await CheckExisitForImport(details);
            return details;
        }
        /// <summary>
        /// æ ¹æ®ç‰ˆæœ¬ä¸‹è½½æŽ§åˆ¶å±žæ€§è§„则明细的Excel导入模板
        /// </summary>
        /// <param name="version">模板版本</param>
        /// <returns>下载的模板文件</returns>
        [HttpGet("WmsControlRuleDetail/downloadExcelTemplate")]
        public IActionResult DownloadExcelTemplate([FromQuery] string version)
        {
            string _path = TemplateConst.EXCEL_TEMPLATEFILE_导入模版路径 + $"\\WmsControlRuleDetail{TemplateConst.EXCEL_TEMPLATEFILE_导入模版名称后缀}.xlsx";
            var fileName = HttpUtility.UrlEncode($"导入模板(控制属性规则明细).xlsx", Encoding.GetEncoding("UTF-8"));
            return new FileStreamResult(new FileStream(_path, FileMode.Open), "application/octet-stream") { FileDownloadName = fileName };
        }
        #endregion
        #region ç§æœ‰æ–¹æ³•
        /// <summary>
        /// æ ¹æ®è”合主键验证数据是否已存在-数据库
        /// </summary>
        /// <param name="input"></param>
        /// <param name="isEdit"></param>
        /// <returns></returns>
        private async Task CheckExisit( WmsControlRuleDetail input,bool isEdit=false)
        {
           bool isExist = false;
           if (!isEdit)//新增
           {
                   //数据是否存在重复
                   isExist = await _wmsControlRuleDetailRep.AnyAsync(u =>
                                   u.ControlRuleId.Equals(input.ControlRuleId)
                   ,false);
          }
           else//编辑
          {
                 //当前编辑数据以外是否存在重复
                  isExist = await _wmsControlRuleDetailRep.AnyAsync(u =>
                                    u.Id != input.Id
                                    &&u.ControlRuleId.Equals(input.ControlRuleId)
                    ,false);
               }
            if (isExist) throw Oops.Oh(ErrorCode.E0001);
       }
        /// <summary>
        /// æ ¹æ®è”合主键验证数据是否已存在-导入时验证
        /// </summary>
        /// <param name="inputs"></param>
        /// <returns></returns>
        private async Task CheckExisitForImport(List<WmsControlRuleDetail> inputs)
        {
            //根据联合主键验证表格中中是否已存在相同数据
                 if (inputs?.Count <= 0)
                 {
                     throw Oops.Oh($"导入数据不能为空");
                 }
                 //数据是否重复
                 var existExcelItem = inputs.GroupBy(g => new {
                                               g.ControlRuleId
                                               })
                                               .Where(g => g.Count() > 1)
                                               .Select(s => new {
                                               s.Key.ControlRuleId
                                               }).FirstOrDefault();
                 if (existExcelItem != null)
                 {
                   var wmsControlRuleDetail = existExcelItem.Adapt<WmsControlRuleDetail>();
                   var item= existExcelItem.Adapt<WmsControlRuleDetail>();
                   throw Oops.Oh($"导入的表格中,控制属性规则ID[{item.ControlRuleId}]已存在");
                 }
    //根据联合主键验证数据库中是否已存在相同数据
                 var existDBItem = await _wmsControlRuleDetailRep.DetachedEntities.FirstOrDefaultAsync(w=>
                                                                         inputs.Select(s=>""
                                                                           +s.ControlRuleId
                                                                        )
                                                                        .Contains(""
                                                                         +w.ControlRuleId
                  ));
                  if (existDBItem != null)
                 {
                   var wmsControlRuleDetail = existExcelItem.Adapt<WmsControlRuleDetail>();
                   var item= existExcelItem.Adapt<WmsControlRuleDetail>();
                   throw Oops.Oh($"系统中,控制属性规则ID[{item.ControlRuleId}]已存在");
                 }
        }
        #endregion
    }
}
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ExcelTemplateFile/WmsControlRuleDetailImport.xlsx
Binary files differ
iWare_RawMaterialWarehouse_Wms/Admin.NET.Web.Entry/wwwroot/ExcelTemplateFile/WmsControlRuleImport.xlsx
Binary files differ