3
2
Переглянути джерело

检测地点、受检单位、安装位置

yuedefeng 6 роки тому
батько
коміт
9be0ace89a

+ 2 - 0
src/dashoo.cn/backend/api/business/limscustomerposition/limscustomerposition.go

@@ -15,6 +15,8 @@ type LimsCustomerPosition struct {
 	PositionTypeId string    `xorm:"comment('位置类型ID') VARCHAR(50)"`
 	ProjectTypeId  int    	 `xorm:"comment('数据录入模板类型ID') INT(10)"`
 	ProjectType    string    `xorm:"comment('数据录入模板名称') VARCHAR(50)"`
+	ThrUnitId	   int    	 `xorm:"comment('三级单位ID') INT(10)"`
+	ThrUnit		   string    `xorm:"comment('三级单位') VARCHAR(500)"`
 	SortCode  	   int    	 `xorm:"comment('排序码') INT(10)"`
 	CreateOn       time.Time `xorm:"DATETIME"`
 	CreateUserId   int       `xorm:"INT(10)"`

+ 15 - 1
src/dashoo.cn/backend/api/business/organize/organizeService.go

@@ -25,7 +25,7 @@ func GetOrganizeService(xormEngine *xorm.Engine) *OrganizeService {
 //获得某节点的所有子节点(包括自身)
 func (s *OrganizeService) GetAllChildByTopId(topid, uid string) string {
 	mod := new(Id_Str)
-	s.DBE.Sql(`select fun_getOrganizechildlistuserid ('` + topid + `','` + uid + `') as Id`).Get(mod)
+	s.DBE.SQL(`select fun_getOrganizechildlistuserid ('` + topid + `','` + uid + `') as Id`).Get(mod)
 	return mod.Id
 }
 
@@ -164,3 +164,17 @@ func (s *OrganizeService) GetMyUnitDepartmentId(topid string) string {
 	}
 	return strconv.Itoa(entity.Id)
 }
+
+func (s *OrganizeService) GetAllThirdChildByTopId(topid, uid string) (entitys []Base_Organize) {
+	ids := s.GetAllChildById(topid)
+	sql := "select * from Base_Organize where"
+	where := " 1=1 "
+	if len(ids) > 0 {
+		where += " and id in (" + ids + ") and Category='ThrUnit'"
+	} else {
+		where += " and 1=0"
+	}
+	sql += where
+	s.DBE.SQL(sql).Find(&entitys)
+	return entitys
+}

+ 2 - 0
src/dashoo.cn/backend/api/controllers/base.go

@@ -325,6 +325,8 @@ func (this *BaseController) Prepare() {
 		this.User.Description = usermodel.Description
 		this.User.DepartmentId = usermodel.Departmentid
 		this.User.Roles = utils.ToStr(usermodel.Roleid)
+		this.User.UnitId = usermodel.UnitId
+		this.User.Uint = usermodel.Unit
 		beego.Debug("User:", this.User)
 	}
 

+ 2 - 0
src/dashoo.cn/backend/api/controllers/casbin/user.go

@@ -88,6 +88,8 @@ func (this *UserController) Get() {
 	user.Profile.IsCompanyUser = usermodel.IsCompanyUser
 	user.Profile.Superior = usermodel.Superior
 	user.Profile.Id = usermodel.Id
+	user.Profile.Uint = usermodel.Unit
+	user.Profile.UintId = usermodel.UnitId
 	// todo 从this.User获取用户名,再查询出具体用户
 	//	user := models.User{"user01", "张三", models.Profile{Gender: "male", Age: 20, Address: "china", Email: "123zs@gmail.com", Realname: "ppppppp"}}
 	this.Data["json"] = user

+ 10 - 0
src/dashoo.cn/backend/api/controllers/lims/Limscustomerposition.go

@@ -1,7 +1,9 @@
 package lims
 
 import (
+	"dashoo.cn/backend/api/business/organize"
 	"encoding/json"
+	"strconv"
 	"strings"
 	"time"
 
@@ -186,6 +188,10 @@ func (this *LimsCustomerpositionController) GetDictList() {
 	userSvc.GetEntityById(this.User.Id, &userEntity)
 	dictList["Supervisers"] = userSvc.GetUserListByDepartmentId(this.User.AccCode, userEntity.Departmentid)
 
+	//三级单位列表
+	organizeSvc := organize.GetOrganizeService(utils.DBE)
+	dictList["ThrUnitList"] = organizeSvc.GetAllThirdChildByTopId( strconv.Itoa(this.User.UnitId), this.User.Id )
+
 	//var dictCustomer []svccustomer.Customer
 	//customerSvc.GetEntitysByWhere(this.User.AccCode + CustomerName, "", &dictCustomer)
 	//dictList["EntrustCorp"] = &dictCustomer
@@ -292,6 +298,10 @@ func (this *LimsCustomerpositionController) UpdateEntity() {
 
 		"ProjectType",
 
+		"ThrUnitId",
+
+		"ThrUnit",
+
 		"SortCode",
 
 		"CreateOn",

+ 2 - 1
src/dashoo.cn/backend/api/controllers/lims/customer.go

@@ -2,6 +2,7 @@ package lims
 
 import (
 	"encoding/json"
+	"strconv"
 	"strings"
 
 	. "dashoo.cn/backend/api/controllers"
@@ -131,7 +132,7 @@ func (this *CustomerController) Getcustomerlist() {
 func (this *CustomerController) GetCustomerByDepartmentId() {
 	var model customer2.Customer
 	svc := customer2.GetCustomerService(utils.DBE)
-	where := "DepartmentId = '" + this.User.DepartmentId + "'"
+	where := "DepartmentId = '" + strconv.Itoa( this.User.UnitId ) + "'"
 	svc.GetEntityByWhere(this.User.AccCode+CustomerName, where, &model)
 	var datainfo DataInfo
 	datainfo.Items = model

+ 1 - 0
src/dashoo.cn/backend/api/models/token.go

@@ -46,6 +46,7 @@ type UserInfo struct {
 	IsCompanyUser int
 	Superior      string
 	Uint          string
+	UnitId        int
 }
 
 // 建立JWT Token

+ 1 - 0
src/dashoo.cn/backend/api/models/user.go

@@ -44,6 +44,7 @@ type Profile struct {
 	IsCompanyUser int
 	Superior      string
 	Uint          string
+	UintId        int
 }
 
 //func AddUser(u User) string {

BIN
src/dashoo.cn/backend/api/static/limsdoc/dataentry/template/pdf/tmp_1557832618.pdf


BIN
src/dashoo.cn/backend/api/static/limsdoc/dataentry/template/pdf/tmp_1557832620.pdf


+ 25 - 10
src/dashoo.cn/frontend_web/src/pages/lims/principal/subdata/customerposition.vue

@@ -56,6 +56,12 @@
     <!--新增、编辑样品类型-->
     <el-dialog title="检测地点信息" :visible.sync="dialogVisible" width="720px" size="small">
       <el-form :model="formData" ref="EntityForm" label-width="120px" label-position="top">
+        <el-form-item label="受检单位" required>
+          <el-select ref="ThrUnitSelect" v-model="formData.ThrUnitId" style="width:100%" placeholder="请选择" filterable >
+            <el-option v-for="item in thrUnitList" :key="item.Id" :label="item.Fullname" :value="item.Id"></el-option>
+          </el-select>
+        </el-form-item>
+
         <el-form-item label="检测地点名称" required>
           <el-input v-model="formData.PositionName" placeholder="请输入"  style="width: 100%"></el-input>
         </el-form-item>
@@ -149,8 +155,8 @@
 </template>
 
 <script>
-  import { mapGetters } from 'vuex';
-  import api from '@/api/lims/customerposition';
+  import { mapGetters } from 'vuex'
+  import api from '@/api/lims/customerposition'
 
   export default {
     computed: {
@@ -175,6 +181,7 @@
         customerOrigList: [],
         projectTypeList: [],
         selectedorg: [],
+        thrUnitList: [],
         selectNodeId: '0',
         selectNodeName: '根节点',
         tmpShowSelectNodeName: '',
@@ -288,7 +295,7 @@
       this.customerCheckBuildList()
       this.gettreelist()
       this.initDatas()
-      //this.getDictOptions()
+      this.getDictOptions()
       this.getProjectType()
     },
     methods: {
@@ -331,20 +338,29 @@
         })
       },
 
-      //保存信息
-      saveEntity() {
+      // 保存信息
+      saveEntity () {
+        if (!this.formData.ThrUnitId) {
+          this.$message({
+            type: 'warning',
+            message: '受检单位不能为空'
+          })
+          return
+        }
+
         this.$refs['EntityForm'].validate((valid) => {
           if (valid) {
             this.formData.CustomerId = this.CustomerId
             this.formData.ParentId = 0
             this.formData.PositionType = '检测地点'
             this.formData.PositionTypeId = '1'
+            this.formData.ThrUnitId = parseInt(this.formData.ThrUnitId)
+            this.formData.ThrUnit = this.$refs['ThrUnitSelect'].selectedLabel
             if (!this.formData.Id) {
               this.addEntity()
             } else {
               this.updateEntity()
             }
-
           } else {
             return false
           }
@@ -442,11 +458,10 @@
         });
       },
 
-      getDictOptions() {
+      getDictOptions () {
         api.getDictList(this.$axios).then(res => {
-          //this.dictOptions.customerList = res.data.items['customerList']
-          //this.dictOptions.projectList = res.data.items['projectList']
-
+          console.log(res.data.items)
+          this.thrUnitList = res.data.items['ThrUnitList']
         }).catch(err => {
           console.error(err)
         })

+ 15 - 10
src/dashoo.cn/frontend_web/src/pages/lims/secondunitform/index.vue

@@ -30,7 +30,7 @@
           </el-col>
           <el-col :span="8">
             <el-form-item label="委托方名称" required prop="CustomerName">
-              <el-input v-model="customerForm.CustomerName" placeholder="请输入委托方名称"></el-input>
+              <el-input v-model="customerForm.CustomerName" placeholder="请输入委托方名称" readonly></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="8">
@@ -67,7 +67,7 @@
         </el-tab-pane>
 
         <el-tab-pane label="设备列表" name="2">
-          <check-equipment-list></check-equipment-list>
+          <check-equipment-list  v-if="this.customerForm.Id"></check-equipment-list>
         </el-tab-pane>
       </el-tabs>
 
@@ -206,7 +206,7 @@
         }]
       }
     },
-    created() {
+    created () {
       this.getCustomerInfo()
     },
     computed: {
@@ -219,12 +219,13 @@
         if (this.customerForm.Id && this.customerForm.Id > 0) {
           this.editCustomer('customerForm')
         } else {
-          this.customerForm.DepartmentId = this.authUser.Profile.DepartmentId
+          this.customerForm.DepartmentId = this.authUser.Profile.UintId + ''
+          this.customerForm.DepartmentName = this.authUser.Profile.Uint + ''
           this.addCustomer('customerForm')
         }
       },
 
-      addCustomer(formName) {
+      addCustomer (formName) {
         let _this = this
         this.$refs[formName].validate((valid) => {
           if (valid) {
@@ -256,7 +257,7 @@
         })
       },
 
-      editCustomer(formName) {
+      editCustomer (formName) {
         let _this = this
         this.$refs[formName].validate((valid) => {
           if (valid) {
@@ -288,15 +289,19 @@
         })
       },
 
-      getCustomerInfo() {
+      getCustomerInfo () {
         let _this = this // request
         this.$axios.get('customer/getcustomerbydepartid', {})
           .then(res => {
             _this.customerForm = res.data.items
+            if (!_this.customerForm.Id) {
+              this.customerForm.CustomerName = this.authUser.Profile.Uint
+              this.customerForm.ViceBusiness = '大港油田'
+            }
           }).catch(err => {
-          // handle error
-          console.error(err)
-        })
+            // handle error
+            console.error(err)
+          })
       },
 
     }