Browse Source

分装预录入分组

shihang 6 years ago
parent
commit
cd0fa9c906

+ 25 - 6
src/dashoo.cn/backend/api/controllers/samplesinfo/samplesubpackage.go

@@ -14,6 +14,7 @@ import (
 	"dashoo.cn/backend/api/business/samplesubpackage"
 	"dashoo.cn/backend/api/business/sampletype"
 	. "dashoo.cn/backend/api/controllers"
+	"dashoo.cn/cellbank/backend/api/business/samplesgroup"
 	"dashoo.cn/utils"
 )
 
@@ -142,7 +143,7 @@ func (this *SampleSubpackageController) SubpackageList() {
 // @Success	200	{object} controllers.Request
 // @router / [post]
 func (this *SampleSubpackageController) Add() {
-
+	var errinfo ErrorDataInfo
 	var jsonblob = this.Ctx.Input.RequestBody
 	var datamain samplesubpackage.SamplesMain
 	var datadetail samplesubpackage.SamplesDetail
@@ -154,6 +155,9 @@ func (this *SampleSubpackageController) Add() {
 	json.Unmarshal(jsonblob, &datamainnew)
 	json.Unmarshal(jsonblob, &datadetailnew)
 	json.Unmarshal(jsonblob, &dataother)
+
+	groupid := this.GetString("groupid")
+	groupname := this.GetString("groupname")
 	subpackagenum := this.GetString("subpackagenum")
 	Subpackagenum, _ := utils.StrTo(subpackagenum).Int()
 	subnum, _ := utils.StrTo(utils.ToStr(subpackagenum)).Float32()
@@ -162,12 +166,13 @@ func (this *SampleSubpackageController) Add() {
 	subpackagecapacity := this.GetString("subpackagecapacity")
 	Subpackagecapacity, _ := utils.StrTo(utils.ToStr(subpackagecapacity)).Float32()
 	UsedCapacity := subnum * Subpackagecapacity
+
 	svc := samplesubpackage.GetSampleSubpackageService(utils.DBE)
+
 	datadetail.IState = 2
-	if datadetail.CreateUserId == 0 {
-		datadetail.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
-		datadetail.CreateBy = this.User.Realname
-	}
+	datadetail.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	datadetail.CreateBy = this.User.Realname
+
 	var err error
 	if datadetail.Capacity > 0 {
 		if datadetail.BarCode == "" {
@@ -186,6 +191,7 @@ func (this *SampleSubpackageController) Add() {
 		datamain.ReceiveDate = time.Unix(dataother.ReceiveDateint/1000, 0)
 		_, err = svc.InsertEntityBytbl(this.User.AccCode+SamplesMaintbName, &datamain)
 	}
+
 	if Subpackagenum > 1 && Subpackagecapacity > 0 {
 		for subcapacity := Subpackagenum; subcapacity > 0; subcapacity-- {
 			datadetailnew.IState = 2
@@ -194,6 +200,19 @@ func (this *SampleSubpackageController) Add() {
 			datadetailnew.BarCode = svc.AutoGetBarCode(this.User.AccCode, datamainnew.SampleCode)
 			datadetailnew.ParentBarCode = datadetail.BarCode
 			_, err = svc.InsertEntityBytbl(this.User.AccCode+SamplesDetailtbName, &datadetailnew)
+			if groupid != "" {
+				var entity samplesgroup.GroupDetail
+				entity.GroupId = groupid
+				entity.GroupName = groupname
+				entity.SampleId = datadetailnew.Id
+				entity.SampleCode = datamain.SampleCode
+				entity.BarCode = datadetailnew.BarCode
+				entity.GroupType = "SampleGroup"
+				entity.CreateBy = this.User.Realname
+				entity.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+				groupSvc := samplesgroup.GetSamplesGroupService(utils.DBE)
+				groupSvc.InsertEntityBytbl(this.User.AccCode+GroupDetailName, &entity)
+			}
 		}
 	}
 
@@ -217,7 +236,7 @@ func (this *SampleSubpackageController) Add() {
 	} else {
 		sisAutoPrintSample = "false"
 	}
-	var errinfo ErrorDataInfo
+
 	saveandadd := dataother.Saveandadd
 	var Auto_Code_Struct AutoCodeStruct
 	if err == nil {

+ 58 - 1
src/dashoo.cn/frontend_web/src/pages/samples/prerecorded/_opera/prerecordedadd.vue

@@ -144,6 +144,15 @@
               </el-select>
             </el-form-item>
           </el-col>
+          <el-col :span="8" v-if="acc =='sryms'">
+            <el-form-item label="所属分组">
+              <el-select ref="refGroup" multiple filterable default-first-option v-model="GroupIdOption" placeholder="请选择"
+                style="width: 100%">
+                <el-option v-for="item in groupList" :key="item.Key" :label="item.Value" :value="item.Id">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
           <el-col :span="24">
             <el-form-item label="备注">
               <el-input v-model="sampleform.Remark" type="textarea" :rows="2" placeholder="样本分装备注"></el-input>
@@ -533,6 +542,11 @@
         // publickzlist: [], // 公共扩展
         userlist: [], // 录入人
 
+        groupList: [], //合作用户分组
+        GroupIdOption: [],
+        GroupId: '',
+        GroupName: '',
+
         Tabs: '',
         groupnameList: [], //扩展字段分组列表
         imageDialog: false,
@@ -551,6 +565,7 @@
       this.getsampetypeunit();
       this.getsametypetreelist();
       this.getautocodedata();
+      this.getGrouplist()
       // this.getpublickz();
       // 获取录入人
       this.getuserlist();
@@ -842,8 +857,25 @@
               })
             }
             _this.samplecodelist.push(_this.SampleCodeOld)
+
+            if (_this.GroupIdOption.length > 0) {
+              _this.GroupId = _this.GroupIdOption.join(',');
+              let tempOfficers = [];
+              for (let idx in this.GroupIdOption) {
+                let selectId = this.GroupIdOption[idx];
+                for (let idx2 in this.groupList) {
+                  let item = this.groupList[idx2];
+                  if (item.Id == selectId) {
+                    tempOfficers.push(item.Value);
+                    break;
+                  }
+                }
+              }
+              _this.GroupName = tempOfficers.join(',');
+            }
             _this.$axios.post('samplesubpackage/?subpackagenum=' + _this.SubpackageNum + '&subpackagecapacity=' +
-                _this.SubpackageCapacity + '&capacity=' + _this.sampleform.Capacity, params)
+                _this.SubpackageCapacity + '&capacity=' + _this.sampleform.Capacity + '&groupid=' + _this.GroupId +
+                '&groupname=' + _this.GroupName, params)
               .then(res => {
                 // response
                 if (res.data.code === 0) {
@@ -1082,6 +1114,31 @@
             console.error(err);
           });
       },
+
+      //合作用户分组处理
+      getGroup(val) {
+        this.$axios.get('samplesgroup/groupbybarcode/' + val, {})
+          .then(res => {
+            this.GroupIdOption = [];
+            if (res.data.GroupId != "") {
+              let tempArr = res.data.GroupId.split(',');
+              for (let idx in tempArr) {
+                this.GroupIdOption.push(parseInt(tempArr[idx]));
+              }
+            }
+          })
+          .catch(err => {
+            // handle error
+            console.error(err)
+          })
+      },
+      getGrouplist() {
+        let _this = this
+        _this.$axios.get('/samplesgroup/grouplist', {})
+          .then(res => {
+            _this.groupList = res.data
+          })
+      },
       //获取当前上传图片字段
       getitem(val) {
         this.imagefiles = ''