LiFei před 5 roky
rodič
revize
a9bd5cb9e4

+ 163 - 0
src/views/requiremanager/modules/CompanySelectWindow.vue

@@ -0,0 +1,163 @@
+<template>
+  <a-modal
+    :width="modalWidth"
+    :visible="visible"
+    title="选择企业"
+    :confirmLoading="confirmLoading"
+    @ok="handleSubmit"
+    @cancel="handleCancel"
+    cancelText="关闭"
+    wrapClassName="ant-modal-cust-warp"
+  >
+    <template>
+      <a-form :form="form">
+        <a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" label="企业">
+          <a-tree
+            :multiple="multipe"
+            checkable
+            :checkedKeys="checkedKeys"
+            allowClear="true"
+            :checkStrictly="true"
+            @check="onCheck"
+            :dropdownStyle="dropDownStyle"
+            :treeData="departTree"
+            placeholder="请选择企业">
+          </a-tree>
+        </a-form-item>
+      </a-form>
+    </template>
+  </a-modal>
+</template>
+
+<script>
+  import pick from 'lodash.pick'
+  import { getAction } from '@/api/manage'
+  import { queryDepartTreeList } from '@/api/api'
+
+
+  export default {
+    name: 'CompanySelectWindow',
+    components: {},
+    data() {
+      return {
+        multipe: false,
+        checkedKeys: [], // 存储选中的服务商id
+        departList: [], // 存储选中的服务商信息
+        modalWidth: 400,
+        departTree: [],
+        title: '操作',
+        visible: false,
+        labelCol: {
+          xs: { span: 24 },
+          sm: { span: 5 }
+        },
+        wrapperCol: {
+          xs: { span: 24 },
+          sm: { span: 16 }
+        },
+        dropDownStyle:{
+          maxHeight:'200px',
+          overflow:'auto'
+        },
+        confirmLoading: false,
+        headers: {},
+        form: this.$form.createForm(this),
+        url: {
+          list: '/hlgcompany/hlgCompany/allCompanyList',//查询所有企业
+        }
+      }
+    },
+    methods: {
+      add(checkedDepartKeys) {
+        this.checkedKeys = checkedDepartKeys;
+        this.edit({})
+      },
+      edit() {
+        this.departList = []
+        this.queryCompanyDepartList()
+        this.form.resetFields()
+        this.visible = true
+      },
+      close() {
+        this.$emit('close')
+        this.visible = false
+        this.departList = []
+        this.checkedKeys = []
+      },
+      handleSubmit() {
+        const that = this
+        // 触发表单验证
+        this.form.validateFields((err) => {
+          if (!err) {
+            that.confirmLoading = true
+            let formData = {
+              departIdList: this.departList
+            }
+            console.log(formData)
+            that.departList = []
+            that.$emit('ok', formData)
+            that.confirmLoading = false
+            that.close()
+          }
+        })
+      },
+      handleCancel() {
+        this.close()
+      },
+
+      // 选择企业时作用的API
+      onCheck(checkedKeys, info) {
+        this.departList = []
+        if(!this.multipe){//单选
+          let arr = checkedKeys.checked.filter(item=>{
+            return this.checkedKeys.indexOf(item)<0
+          })
+          this.checkedKeys = [...arr]
+          let checkedNodes = info.checkedNodes
+          for (let i = 0; i < checkedNodes.length; i++) {
+            let de = checkedNodes[i].data.props
+            console.log(1111,de)
+            let depart = { key: '', value: '',title:""}
+            depart.key = de.id
+            depart.value = de.id
+            depart.title = de.departName;
+            this.departList[0] = depart
+          }
+        }else{//多选
+          this.checkedKeys = checkedKeys.checked
+          let checkedNodes = info.checkedNodes
+          for (let i = 0; i < checkedNodes.length; i++) {
+            let de = checkedNodes[i].data.props
+            let depart = { key: '', value: '',title:""}
+            depart.key = de.id
+            depart.value = de.id
+            depart.title = de.departName;
+            this.departList.push(depart)
+          }
+        }
+        console.log('onCheck', checkedKeys, info)
+      },
+      //查询所有企业列表
+      queryCompanyDepartList() {
+        queryDepartTreeList().then((res) => {
+          if (res.success) {
+            for(let i = 0;i<res.result.length;i++){
+              res.result[i].title = res.result[i].departName;
+            }
+            this.departTree = res.result
+          }
+        })
+      },
+      modalFormOk() {
+
+      }
+    }
+  }
+</script>
+
+<style scoped>
+  .ant-table-tbody .ant-table-row td {
+    padding-top: 10px;
+    padding-bottom: 10px;
+  }
+</style>

+ 75 - 15
src/views/requiremanager/modules/HwRequirementModal.vue

@@ -13,8 +13,21 @@
     <a-spin :spinning="confirmLoading">
       <a-form :form="form">
 
+
+
         <a-form-item label="发布企业" :labelCol="labelCol" :wrapperCol="wrapperCol" v-has="'require:saas'" :required="true">
-          <j-select-depart v-decorator="['companyId']" :trigger-change="true" style="width: 100%"/>
+          <template v-if="!model.id">
+            <a-input-search
+              placeholder="选择企业"
+              disabled
+              v-decorator="[ 'companyName', validatorRules.companyId]"
+              @search="onSearch1">
+              <a-button slot="enterButton" icon="search" v-if="!model.id">选择</a-button>
+            </a-input-search>
+          </template>
+          <template v-else>
+            <a-input v-decorator="[ 'companyName', validatorRules.companyId]"  :disabled="true"></a-input>
+          </template>
         </a-form-item>
 
 
@@ -128,12 +141,13 @@
       <a-button class="ant-btn"  @click="handleCancel">取消</a-button>
       <a-button class="ant-btn ant-btn-primary" style="margin-left: 8px"  @click="handleOk">确定</a-button>
     </div>
+    <company-select-window ref="companyWindow" @ok="modalFormOk1"></company-select-window>
   </a-modal>
 </template>
 
 <script>
   import { USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
-  import { httpAction } from '@/api/manage'
+  import { httpAction,getAction } from '@/api/manage'
   import pick from 'lodash.pick'
   import JDate from '@/components/jeecg/JDate'
   import JUpload from '@/components/jeecg/JUpload'
@@ -143,6 +157,7 @@
   import Vue from 'vue'
   import { ACCESS_TOKEN } from '@/store/mutation-types'
   import moment from 'moment'
+  import CompanySelectWindow from './CompanySelectWindow'
 
   const FILE_TYPE_ALL = "all"
   const FILE_TYPE_PDF = 'pdf'
@@ -160,6 +175,7 @@
   export default {
     name: 'HwRequirementModal',
     components: {
+      CompanySelectWindow,
       JDate,
       JUpload,
       JSelectDepart,
@@ -202,6 +218,9 @@
           isLeaf: false
         }],
         confirmLoading: false,
+        selectedDepartKeys1:[], //保存用户选择企业id
+        checkedDepartKeys1:[],
+        companyId:0,
         validatorRules: {
           companyId:{ rules: [{ required: true, message: '请输入所属平台企业!' }] },
           platformCompanyId: { rules: [{ required: true, message: '请输入所属平台企业!' }] },
@@ -231,7 +250,8 @@
         url: {
           fileUpload: window._CONFIG['domianURL'] + '/hpSys/common/ossUpload',
           add: '/requiremanager/hwRequirement/add',
-          edit: '/requiremanager/hwRequirement/edit'
+          edit: '/requiremanager/hwRequirement/edit',
+          queryInfo:'/requiremanager/hwRequirement/queryInfo',
         }
 
       }
@@ -321,6 +341,9 @@
           this.form.setFieldsValue({ serviceTimeRange:this.model.serviceStartDate!=null?[moment(this.model.serviceStartDate, 'YYYY/MM/DD'), moment(this.model.serviceEndDate, 'YYYY/MM/DD')]:[]})
           // console.log(this.model.serviceStartDate)
           // console.log( this.model.serviceEndDate)
+          this.selectedDepartKeys1 = [];
+          this.checkedDepartKeys1 = [];
+          this.companyId=0
 
         })
 
@@ -365,17 +388,6 @@
           this.model.workContractType=null
           this.model.authenticationStatus=0
         }
-        var companyId = this.form.getFieldValue('companyId');
-        if(!companyId){
-          //获取页面权限
-          let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || "[]");
-          for (var auth of authList) {
-            if(auth.action == 'require:saas') {
-              this.$message.warning('请选择企业')
-              return;
-            }
-          }
-        }
         // if(this.model.contractType ==0){
         //   if(!this.model.serviceContract || this.fileList.length==0){
         //     this.$message.warning('请上传企业合同')
@@ -412,6 +424,9 @@
 
             let formData = Object.assign(this.model, values)
             formData.expiryDate=this.model.expiryDate+" 23:59:59"
+            if(this.selectedDepartKeys1[0]){
+              formData.companyId=this.companyId
+            }
             console.log('表单提交数据', formData)
             httpAction(httpurl, formData, method).then((res) => {
               if (res.success) {
@@ -419,7 +434,15 @@
                 that.$emit('ok')
                 that.close()
               } else {
-                that.$message.warning(res.message)
+                this.$error({
+                  title: '提示',
+                  content: res.message,
+                  okText: '确定',
+                  centered:true,
+                  onOk: () => {
+
+                  }
+                })
               }
             }).finally(() => {
               that.confirmLoading = false
@@ -580,6 +603,43 @@
       viewContract(file){
         window.open(window._CONFIG['imgDomainOssURL']+this.model.serviceContract, '_blank', 'toolbar=yes')
       },
+
+      //搜索企业
+      onSearch1(){
+        this.$refs.companyWindow.add(this.checkedDepartKeys1);
+      },
+      // 获取用户选择企业提交的返回数据
+      modalFormOk1 (formData) {
+        this.selectedDepartKeys1 = [];
+        for (let i = 0; i < formData.departIdList.length; i++) {
+          this.selectedDepartKeys1.push(formData.departIdList[i].key);
+          this.form.setFieldsValue({ companyName: formData.departIdList[i].title })
+        }
+        this.checkedDepartKeys1 = this.selectedDepartKeys1  //更新当前的选择keys
+        if(this.selectedDepartKeys1[0]){
+          this.companyId = this.selectedDepartKeys1[0];
+          getAction(this.url.queryInfo,{companyId:this.companyId}).then((res)=>{
+            console.log(222,res.message)
+            if(res.success){
+
+            }else{
+              this.$error({
+                title: '提示',
+                content: res.message,
+                okText: '确定',
+                centered:true,
+                onOk: () => {
+
+                }
+              })
+            }
+          });
+        }
+      },
+
+
+
+
     }
   }
 </script>