Selaa lähdekoodia

申请单增加采购组织和业务部门参照及字段

黄梓星 2 vuotta sitten
vanhempi
commit
f19095986a

+ 10 - 1
src/api/requisition/basic.js

@@ -79,11 +79,20 @@ export function getLine(data) {
     data: data
   })
 }
-// 参照-剂型
+// 参照-剂型-树形
 export function getDose(data) {
   return request({
     url: `/system/archival/queryDosageForm`,
     method: 'post',
     data: data
   })
+}
+// 参照-采购组织-树形
+// 查询部门下拉树结构
+export function getOrgs(data) {
+  return request({
+    url: '/system/user/deptTree',
+    method: 'get',
+    params: data
+  })
 }

+ 129 - 0
src/components/PopDialog/organization.vue

@@ -0,0 +1,129 @@
+<template>
+  <div>
+    <el-dialog
+      title="采购组织选择"
+      width="500px"
+      :close-on-click-modal="false"
+      :append-to-body="true"
+      v-dialogDrag
+      class="userDialog"
+      :visible.sync="visible"
+    >
+      <el-container style="height: 500px">
+        <el-container>
+          <el-main>
+            <el-row :gutter="10" class="content">
+              <el-col :span="12">
+                <el-input
+                  placeholder="输入关键字进行过滤"
+                  size="small"
+                  v-model="filterText">
+                </el-input>
+
+                <el-tree
+                  class="filter-tree"
+                  :data="threedata"
+                  :props="defaultProps"
+                  node-key="id"
+                  highlight-current
+                  @node-click="clickTree"
+                  :filter-node-method="filterNode"
+                  ref="tree">
+                </el-tree>
+              </el-col>
+            </el-row>
+          </el-main>
+        </el-container>
+      </el-container>
+      <span slot="footer" class="dialog-footer">
+        <el-button
+          size="small"
+          @click="visible = false"
+          icon="el-icon-circle-close"
+          >关闭</el-button
+        >
+        <el-button
+          size="small"
+          type="primary"
+          icon="el-icon-circle-check"
+          @click="doSubmit()"
+          >确定</el-button
+        >
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { getOrgs } from '@/api/requisition/basic'
+export default {
+  data() {
+    return {
+      loading: false,
+      visible: false,
+      filterText: '',
+      threedata: [],
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      },
+      // 判断是否为最末级节点
+      // isLast: false,
+      // 选中的节点
+      choosePoint: {},
+    };
+  },
+  props: {},
+  methods: {
+    init(val) {
+      this.visible = true;
+      this.$nextTick(() => {
+        console.log('接收参数了吗', val)
+        this.refreshList(val)
+      });
+    },
+    // 获取数据列表
+    refreshList(val) {
+      this.loading = true;
+      getOrgs({type: val}).then(res => {
+        console.log('res',res)
+        if(res.code === 200) {
+          this.threedata = res.data
+        }
+        this.loading = false;
+      });
+    },
+    clickTree(data) {
+      console.log('节点信息', data)
+      this.choosePoint = data
+    },
+    filterNode(value, data) {
+      console.log('value', value)
+      console.log('data', data)
+        if (!value) return true;
+        return data.label.indexOf(value) !== -1;
+    },
+    doSubmit() {
+      console.log('子组件选择的数据',this.choosePoint)
+      this.$emit("doSubmit", this.choosePoint);
+      this.visible = false;
+    },
+  },
+};
+</script>
+<style lang="scss">
+.userDialog {
+  .el-dialog__body {
+    padding: 10px 0px 0px 10px;
+    color: #606266;
+    font-size: 14px;
+    word-break: break-all;
+  }
+  .el-main {
+    padding: 20px 20px 5px 20px;
+    .el-pagination {
+      margin-top: 5px;
+    }
+  }
+}
+</style>

+ 136 - 17
src/views/material/requisition/add.vue

@@ -517,13 +517,56 @@
           </el-row>
           <el-row :gutter="20">
             <el-col :span="8">
+              <el-form-item label="默认采购组织" prop="purchasingOrganization">
+                <el-select
+                    ref="organizations"
+                    v-model="basicForm.purchasingOrganization"
+                    placeholder="请选择"
+                    clearable
+                    :disabled="disable"
+                    @clear="controlOrg"
+                    @focus="chooseOrganizations"
+                  >
+                    <el-option
+                      v-for="item in organizationsOptions"
+                      :key="item.id"
+                      :label="item.label"
+                      :value="item.id"
+                    />
+                </el-select>
+                <!-- <el-input disabled v-model="basicForm.purchasingOrganization"></el-input> -->
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="业务部门" prop="businessDepartment">
+                <el-select
+                    ref="departs"
+                    v-model="basicForm.businessDepartment"
+                    placeholder="请选择"
+                    clearable
+                    :disabled = "disable || orgControl"
+                    @focus="chooseDepart"
+                  >
+                    <el-option
+                      v-for="item in departOptions"
+                      :key="item.id"
+                      :label="item.label"
+                      :value="item.id"
+                    />
+                </el-select>
+                <!-- <el-input :disabled = "disable || orgControl" v-model="basicForm.businessDepartment"></el-input> -->
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
               <el-form-item label="启用状态" prop="isEnable">
                 <el-input disabled v-model="basicForm.isEnable"></el-input>
               </el-form-item>
             </el-col>
+          </el-row>
+          <el-row :gutter="20">
             <el-col :span="8">
               <el-form-item label="备注" prop="remark">
-                <el-input :disabled="disable" v-model="basicForm.remark"></el-input>
+                <el-input disabled v-model="basicForm.remark"></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -669,17 +712,6 @@
         </el-row> -->
       </el-tab-pane>
 
-      <!-- <el-tab-pane label="修改记录" name="third">
-        <el-table 
-          :data="basicForm.changeRecords"
-          class="request-table"
-          >
-          <el-table-column label="字段名称" align="center" prop="pageCondtion" />
-          <el-table-column label="变更前" align="center" prop="beforeChangeValue" />
-          <el-table-column label="变更后" align="center" prop="afterChangeValue" />
-        </el-table>
-      </el-tab-pane> -->
-
       <el-tab-pane label="单据信息" name="fourth">
         <el-form :model="basicForm" ref="info" label-width="160px">
           <el-row :gutter="20">
@@ -823,6 +855,20 @@
       :selectData="selectData9"
       :single="true"
     />
+
+    <orgs
+      ref="orgs"
+      @doSubmit="acceptOrgs"
+      :selectData="selectData10"
+      :single="true"
+    />
+
+    <depart
+      ref="depart"
+      @doSubmit="acceptDepart"
+      :selectData="selectData11"
+      :single="true"
+    />
   </div>
 </template>
 
@@ -836,13 +882,16 @@ import tax from '@/components/PopDialog/tax.vue'
 import staff from '@/components/PopDialog/staff.vue'
 import serviceline from '@/components/PopDialog/serviceline.vue'
 import dose from '@/components/PopDialog/dose.vue'
+import orgs from '@/components/PopDialog/organization.vue'
+import depart from '@/components/PopDialog/organization.vue'
+// 公用一个树形
 import { addReq, getReqDetail, editReq } from '@/api/requisition/basic'
 // 调用物料分类详情接口用于数据回显
 import { getDetail } from '@/api/classify/basic';
 // 生产厂商/代理人调用用于回显
 import { getProductFactory } from '@/api/changeApply/basic'
 // 计量单位,产地调用用于回显
-import { getUnit, getPlace, getTax, getStaff, getLine, getDose} from '@/api/requisition/basic'
+import { getUnit, getPlace, getTax, getStaff, getLine, getDose, getOrgs} from '@/api/requisition/basic'
 
 export default {
   name: 'requisition_add',
@@ -856,7 +905,9 @@ export default {
     tax,
     staff,
     serviceline,
-    dose
+    dose,
+    orgs,
+    depart
   },
   props: ['pageStu', 'row', 'disable'],
   model: {
@@ -873,8 +924,11 @@ export default {
       staffOptions: [],
       lineOptions: [],
       doseOptions: [],
+      organizationsOptions: [],
+      departOptions: [],
       tabValue: 'first',
       isControl: true,
+      orgControl: true,
       basicForm: {
         billCode: '',
         orgId: '',
@@ -929,6 +983,10 @@ export default {
         oneClass: '',
         twoClass: '',
         threeClass: '',
+        // 新增默认采购组织
+        purchasingOrganization: '',
+        // 新增业务部门
+        businessDepartment: '',
         isEnable: '',
         remark: '',
         // 物料申请单-单据信息
@@ -1002,7 +1060,9 @@ export default {
       selectData6: [],
       selectData7: [],
       selectData8: [],
-      selectData9: []
+      selectData9: [],
+      selectData10: [],
+      selectData11: []
     }
   },
   // watch: {
@@ -1070,6 +1130,12 @@ export default {
       console.log('页面状态',this.pageStu)
       console.log('数据', this.row)
       this.getDetails(this.row)
+      // 控制业务部门是否能够填写
+      if (this.row.purchasingOrganization) {
+        this.orgControl = false
+      } else {
+        this.orgControl = true
+      }
       // 控制医药属性是否能够填写
       if (this.row.isMedicine == '0') {
         this.isControl = false
@@ -1114,9 +1180,14 @@ export default {
       console.log(tab, event);
       console.log('页面状态',this.pageStu)
     },
+    // 选择采购组织时控制业务部门
+    controlOrg(val) {
+      this.basicForm.businessDepartment = ''
+      this.orgControl = true
+    },
     // 选择是否医药物料时控制医药属性
     controlMedic(val) {
-      console.log('val',val)
+      console.log('val1111111',val)
       if (val == '0') {
         this.isControl = false
       } else {
@@ -1205,12 +1276,36 @@ export default {
         }
       })
     },
+    // 采购组织回显
+    getOrgDetails(id) {
+      getOrgs({deptId: id}).then(res => {
+        if (res.code === 200) {
+          this.organizationsOptions = res.data
+        }
+      })
+    },
+    // 业务部门回显
+    getDepartDetails(id) {
+      getOrgs({deptId: id}).then(res => {
+        if (res.code === 200) {
+          this.departOptions = res.data
+        }
+      })
+    },
     // 如果是详情进入,则调用详情接口
     getDetails(row) {
       getReqDetail(row.id).then(res => {
         console.log('res',res)
         if(res.code === 200) {
           this.basicForm = res.data
+          if(res.data.purchasingOrganization) {
+            this.basicForm.purchasingOrganization = res.data.purchasingOrganization
+            this.getOrgDetails(res.data.purchasingOrganization)
+          }
+          if(res.data.businessDepartment) {
+            this.basicForm.businessDepartment = res.data.businessDepartment
+            this.getDepartDetails(res.data.businessDepartment)
+          }
           if(res.data.unitId) {this.basicForm.unitId = res.data.unitId.toString()}
           if(res.data.manufacturerId) {this.basicForm.manufacturerId = res.data.manufacturerId.toString()}
           if(res.data.usefulLifeUnitId) {this.basicForm.usefulLifeUnitId = res.data.usefulLifeUnitId.toString()}
@@ -1451,11 +1546,35 @@ export default {
       this.basicForm2.dosageFrom = selections.id
       this.getDoseDetails(selections.id)
     },
-    // 业务线显示列表
+    // 剂型显示列表
     chooseDose () {
       this.$refs.doses.blur()
       this.$refs.dose.init()
     },
+    // 选择默认采购组织
+    acceptOrgs (selections) {
+      console.log('接收的采购组织', selections)
+      this.basicForm.purchasingOrganization = selections.id
+      // 控制业务部门是否可以选择
+      this.orgControl = false
+      this.getOrgDetails(selections.id)
+    },
+    // 默认采购组织显示列表
+    chooseOrganizations () {
+      this.$refs.organizations.blur()
+      this.$refs.orgs.init('1')
+    },
+    // 选择业务部门
+    acceptDepart (selections) {
+      console.log('接收的业务部门', selections)
+      this.basicForm.businessDepartment = selections.id
+      this.getDepartDetails(selections.id)
+    },
+    // 业务部门显示列表
+    chooseDepart () {
+      this.$refs.departs.blur()
+      this.$refs.depart.init('0')
+    }
   }
 }
 </script>