shenji 2 лет назад
Родитель
Сommit
13121e9d20
2 измененных файлов с 433 добавлено и 0 удалено
  1. 207 0
      src/views/oa/InventoryRecordsList.vue
  2. 226 0
      src/views/oa/modules/InventoryRecordsModal.vue

+ 207 - 0
src/views/oa/InventoryRecordsList.vue

@@ -0,0 +1,207 @@
+<template>
+  <a-card :bordered="false">
+    <!-- 查询区域 -->
+    <div class="table-page-search-wrapper">
+      <a-form layout="inline" @keyup.enter.native="searchQuery">
+        <a-row :gutter="24">
+
+        </a-row>
+      </a-form>
+    </div>
+    <!-- 查询区域-END -->
+    
+    <!-- 操作按钮区域 -->
+    <div class="table-operator">
+      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
+      <a-button type="primary" icon="download" @click="handleExportXls('盘点表')">导出</a-button>
+      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
+        <a-button type="primary" icon="import">导入</a-button>
+      </a-upload>
+      <a-dropdown v-if="selectedRowKeys.length > 0">
+        <a-menu slot="overlay">
+          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
+        </a-menu>
+        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
+      </a-dropdown>
+    </div>
+
+    <!-- table区域-begin -->
+    <div>
+      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
+        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
+        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
+      </div>
+
+      <a-table
+        ref="table"
+        size="middle"
+        bordered
+        rowKey="id"
+        :columns="columns"
+        :dataSource="dataSource"
+        :pagination="ipagination"
+        :loading="loading"
+        :rowSelection="{fixed:true,selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
+        
+        @change="handleTableChange">
+
+        <template slot="htmlSlot" slot-scope="text">
+          <div v-html="text"></div>
+        </template>
+        <template slot="imgSlot" slot-scope="text">
+          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
+          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
+        </template>
+        <template slot="fileSlot" slot-scope="text">
+          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
+          <a-button
+            v-else
+            :ghost="true"
+            type="primary"
+            icon="download"
+            size="small"
+            @click="uploadFile(text)">
+            下载
+          </a-button>
+        </template>
+
+        <span slot="action" slot-scope="text, record">
+          <a @click="handleEdit(record)">编辑</a>
+
+          <a-divider type="vertical" />
+          <a-dropdown>
+            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
+            <a-menu slot="overlay">
+              <a-menu-item>
+                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
+                  <a>删除</a>
+                </a-popconfirm>
+              </a-menu-item>
+            </a-menu>
+          </a-dropdown>
+        </span>
+
+      </a-table>
+    </div>
+
+    <inventoryRecords-modal ref="modalForm" @ok="modalFormOk"></inventoryRecords-modal>
+  </a-card>
+</template>
+
+<script>
+
+  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+  import InventoryRecordsModal from './modules/InventoryRecordsModal'
+
+  export default {
+    name: "InventoryRecordsList",
+    mixins:[JeecgListMixin],
+    components: {
+      InventoryRecordsModal
+    },
+    data () {
+      return {
+        description: '盘点表管理页面',
+        // 表头
+        columns: [
+          {
+            title: '#',
+            dataIndex: '',
+            key:'rowIndex',
+            width:60,
+            align:"center",
+            customRender:function (t,r,index) {
+              return parseInt(index)+1;
+            }
+          },
+          {
+            title:'盘点日期',
+            align:"center",
+            dataIndex: 'checkDate'
+          },
+          {
+            title:'资产编码',
+            align:"center",
+            dataIndex: 'assetEncoding'
+          },
+          {
+            title:'资产名称',
+            align:"center",
+            dataIndex: 'assetName'
+          },
+          {
+            title:'资产类别',
+            align:"center",
+            dataIndex: 'assetsCategory'
+          },
+          {
+            title:'规格型号',
+            align:"center",
+            dataIndex: 'specificationsModels'
+          },
+          {
+            title:'原值',
+            align:"center",
+            dataIndex: 'originalValue'
+          },
+          {
+            title:'购置日期',
+            align:"center",
+            dataIndex: 'carAcquisitionDate'
+          },
+          {
+            title:'使用年限',
+            align:"center",
+            dataIndex: 'durableYears'
+          },
+          {
+            title:'存放地点',
+            align:"center",
+            dataIndex: 'storageLocation'
+          },
+          {
+            title:'使用人',
+            align:"center",
+            dataIndex: 'usePersonnel'
+          },
+          {
+            title:'使用部门',
+            align:"center",
+            dataIndex: 'useDepartment'
+          },
+          {
+            title:'资产状态',
+            align:"center",
+            dataIndex: 'assetState'
+          },
+          {
+            title: '操作',
+            dataIndex: 'action',
+            align:"center",
+            scopedSlots: { customRender: 'action' }
+          }
+        ],
+        url: {
+          list: "/oa/inventoryRecords/list",
+          delete: "/oa/inventoryRecords/delete",
+          deleteBatch: "/oa/inventoryRecords/deleteBatch",
+          exportXlsUrl: "/oa/inventoryRecords/exportXls",
+          importExcelUrl: "oa/inventoryRecords/importExcel",
+        },
+        dictOptions:{},
+      }
+    },
+    computed: {
+      importExcelUrl: function(){
+        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
+      }
+    },
+    methods: {
+      initDictConfig(){
+      }
+    }
+  }
+</script>
+<style scoped>
+  @import '~@assets/less/common.less';
+</style>

+ 226 - 0
src/views/oa/modules/InventoryRecordsModal.vue

@@ -0,0 +1,226 @@
+<template>
+  <a-modal
+    :title="title"
+    :width="width"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @ok="handleOk"
+    @cancel="handleCancel"
+    cancelText="关闭">
+    <a-spin :spinning="confirmLoading">
+      <a-form :form="form">
+
+        <a-form-item label="盘点日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <j-date placeholder="请选择盘点日期" v-decorator="[ 'checkDate', validatorRules.checkDate]" :trigger-change="true" style="width: 100%"/>
+        </a-form-item>
+        <a-form-item label="资产编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-select placeholder="请选择" v-decorator="[ 'assetEncoding', validatorRules.assetEncoding]" @change="handleChange" >
+            <!-- <a-select-option :value="undefined">请选择</a-select-option> -->
+            <a-select-option
+              v-for="(item,index) in assets"
+              :key="index"
+              :value="item.assetNumber">
+              {{ item.assetNumber }}
+            </a-select-option>
+          </a-select>
+        </a-form-item>
+        <a-form-item label="资产名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'assetName', validatorRules.assetName]" placeholder="请输入资产名称"  ></a-input>
+        </a-form-item>
+        <a-form-item label="资产类别" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'assetsCategory', validatorRules.assetsCategory]" placeholder="请输入资产类别" disabled></a-input>
+        </a-form-item>
+        <a-form-item label="规格型号" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'specificationsModels', validatorRules.specificationsModels]" placeholder="请输入规格型号" disabled></a-input>
+        </a-form-item>
+        <a-form-item label="原值" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'originalValue', validatorRules.originalValue]" placeholder="请输入原值" disabled></a-input>
+        </a-form-item>
+        <a-form-item label="购置日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'carAcquisitionDate', validatorRules.carAcquisitionDate]" placeholder="请输入购置日期" disabled></a-input>
+        </a-form-item>
+        <a-form-item label="使用年限" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'durableYears', validatorRules.durableYears]" placeholder="请输入使用年限" disabled></a-input>
+        </a-form-item>
+        <a-form-item label="存放地点" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <a-input v-decorator="[ 'storageLocation', validatorRules.storageLocation]" placeholder="请输入存放地点"></a-input>
+        </a-form-item>
+        <a-form-item label="使用人" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <j-select-user-by-dep v-decorator="['usePersonnel', validatorRules.usePersonnel]" :trigger-change="true" />
+        </a-form-item>
+        <a-form-item label="使用部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <j-select-depart v-decorator="['useDepartment', validatorRules.useDepartment]" :trigger-change="true" customReturnField="departName"/>
+        </a-form-item>
+        <a-form-item label="资产状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <j-dict-select-tag type="list" v-decorator="['assetState', validatorRules.assetState]" :trigger-change="true" dictCode="assets_status" placeholder="请选择资产状态"/>
+        </a-form-item>
+        <a-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
+          <j-upload v-decorator="['accessory', validatorRules.accessory]" :trigger-change="true"></j-upload>
+        </a-form-item>
+
+      </a-form>
+    </a-spin>
+  </a-modal>
+</template>
+
+<script>
+
+  import { httpAction, getAction } from '@/api/manage'
+  import pick from 'lodash.pick'
+  import { validateDuplicateValue } from '@/utils/util'
+  import JDate from '@/components/jeecg/JDate'  
+  import JUpload from '@/components/jeecg/JUpload'
+  import JSelectDepart from '@/components/jeecgbiz/JSelectDepart'
+  import JSelectUserByDep from '@/components/jeecgbiz/JSelectUserByDep'
+  import JDictSelectTag from "@/components/dict/JDictSelectTag"
+  import moment from 'moment'
+
+  export default {
+    name: "InventoryRecordsModal",
+    components: { 
+      JDate,
+      JUpload,
+      JSelectDepart,
+      JSelectUserByDep,
+      JDictSelectTag,
+    },
+    data () {
+      return {
+        form: this.$form.createForm(this),
+        title:"操作",
+        width:800,
+        visible: false,
+        model: {},
+        labelCol: {
+          xs: { span: 24 },
+          sm: { span: 5 },
+        },
+        wrapperCol: {
+          xs: { span: 24 },
+          sm: { span: 16 },
+        },
+        confirmLoading: false,
+        validatorRules: {
+          checkDate: {rules: [
+          ]},
+          assetEncoding: {rules: [
+          ]},
+          assetName: {rules: [
+          ]},
+          assetsCategory: {rules: [
+          ]},
+          specificationsModels: {rules: [
+          ]},
+          originalValue: {rules: [
+          ]},
+          carAcquisitionDate: {rules: [
+          ]},
+          durableYears: {rules: [
+          ]},
+          storageLocation: {rules: [
+          ]},
+          usePersonnel: {rules: [
+          ]},
+          useDepartment: {rules: [
+          ]},
+          assetState: {rules: [
+          ]},
+          accessory: {rules: [
+          ]},
+        },
+        url: {
+          add: "/oa/inventoryRecords/add",
+          edit: "/oa/inventoryRecords/edit",
+          allAssets: "/oa/assets/all",
+        },
+        assets: []
+      }
+    },
+    mounted () {
+      this.initAssets()
+    },
+    methods: {
+      add () {
+        this.edit({});
+      },
+      edit (record) {
+        this.form.resetFields();
+        this.model = Object.assign({}, record);
+        this.visible = true;
+        this.$nextTick(() => {
+          this.form.setFieldsValue(pick(this.model,'checkDate','assetEncoding','assetName','assetsCategory','specificationsModels','originalValue','carAcquisitionDate','durableYears','storageLocation','usePersonnel','useDepartment','assetState','accessory'))
+        })
+      },
+      close () {
+        this.$emit('close');
+        this.visible = false;
+      },
+      handleOk () {
+        const that = this;
+        // 触发表单验证
+        this.form.validateFields((err, values) => {
+          if (!err) {
+            that.confirmLoading = true;
+            let httpurl = '';
+            let method = '';
+            if(!this.model.id){
+              httpurl+=this.url.add;
+              method = 'post';
+            }else{
+              httpurl+=this.url.edit;
+               method = 'put';
+            }
+            let formData = Object.assign(this.model, values);
+            console.log("表单提交数据",formData)
+            httpAction(httpurl,formData,method).then((res)=>{
+              if(res.success){
+                that.$message.success(res.message);
+                that.$emit('ok');
+              }else{
+                that.$message.warning(res.message);
+              }
+            }).finally(() => {
+              that.confirmLoading = false;
+              that.close();
+            })
+          }
+         
+        })
+      },
+      handleCancel () {
+        this.close()
+      },
+      popupCallback(row){
+        this.form.setFieldsValue(pick(row,'checkDate','assetEncoding','assetName','assetsCategory','specificationsModels','originalValue','carAcquisitionDate','durableYears','storageLocation','usePersonnel','useDepartment','assetState','accessory'))
+      },
+      initAssets(){
+        getAction(this.url.allAssets).then((res)=>{
+          if(res.success){
+            this.assets = res.result
+          }else {
+            this.$message.warning(res.message)
+          }
+        })
+      },
+      handleChange(val,op){
+        var asset = this.assets.find(i=>{
+          return i.assetNumber===val
+        })
+        console.log(asset)
+        debugger
+        let durableYears  =  moment(asset.acquisitionDate,"YYYY-MM-DD").diff(moment(),"year")
+        this.form.setFieldsValue({
+          assetName:asset.assetName,
+          assetsCategory:asset.assetsCategory,
+          specificationsModels:asset.specificationsModels,
+          originalValue:asset.unitPrice,
+          carAcquisitionDate:asset.acquisitionDate,
+          durableYears:durableYears,
+        })
+        
+      }
+
+      
+    }
+  }
+</script>