huahaiyan пре 6 година
родитељ
комит
4f6d612eee

+ 26 - 10
src/dashoo.cn/backend/api/business/limsdataentry/limsdataentry.go

@@ -185,16 +185,16 @@ type LimsDateEntry struct {
 	DetectBasis        string    `xorm:"VARCHAR(500)"`
 	StandardDesc       string    `xorm:"VARCHAR(500)"`
 	CheckDate          time.Time `xorm:"DATETIME"`
-	TBModel            string    `xorm:"VARCHAR(20)"` // 试块型号
-	ScanSnty           string    `xorm:"VARCHAR(20)"` // 扫查灵敏度
-	ScanRegu           string    `xorm:"VARCHAR(20)"` // 扫查调节
-	ScanMode           string    `xorm:"VARCHAR(20)"` // 扫查方式
-	TestLoc            string    `xorm:"VARCHAR(20)"` // 检测部位
-	Couplant           string    `xorm:"VARCHAR(20)"` // 耦合剂
-	Comp               float64    `xorm:"DECIMAL(10,2)"` // 补偿
-	UPRange            string    `xorm:"VARCHAR(20)"` // 声程范围
-	SVRange            float64    `xorm:"DECIMAL(10,2)"` //声速范围
-	UTNumber           string    `xorm:"VARCHAR(20)"` // 超声波 编号
+	TBModel            string    `xorm:"VARCHAR(20)"`   // 试块型号
+	ScanSnty           string    `xorm:"VARCHAR(20)"`   // 扫查灵敏度
+	ScanRegu           string    `xorm:"VARCHAR(20)"`   // 扫查调节
+	ScanMode           string    `xorm:"VARCHAR(20)"`   // 扫查方式
+	TestLoc            string    `xorm:"VARCHAR(20)"`   // 检测部位
+	Couplant           string    `xorm:"VARCHAR(20)"`   // 耦合剂
+	Comp               float64   `xorm:"DECIMAL(10,2)"` // 补偿
+	UPRange            string    `xorm:"VARCHAR(20)"`   // 声程范围
+	SVRange            float64   `xorm:"DECIMAL(10,2)"` //声速范围
+	UTNumber           string    `xorm:"VARCHAR(20)"`   // 超声波 编号
 
 	CheckBy        string    `xorm:"VARCHAR(50)"`
 	CreatedTime    time.Time `xorm:"DATETIME created"` //创建时间
@@ -484,3 +484,19 @@ type UserModel struct {
 	DepartmentId   string `json:"departmentid"`
 	DepartmentName string `json:"departmentname"`
 }
+
+//数据录入附件
+type LimsDateEntryAttach struct {
+	Id             int       `xorm:"not null pk autoincr INT(10)"`
+	FileUrl        string    `xorm:"VARCHAR(255)"`
+	FileName       string    `xorm:VARCHAR(50)`
+	DateEntryId    int       `xorm:"INT(10)"`
+	FileType       int       `xorm:"INT(10)"`
+	Remark         string    `xorm:VARCHAR(255)`       //描述
+	CreateOn       time.Time `xorm:"DATETIME created"` //创建时间
+	CreateUserId   int       `xorm:"INT(10)"`
+	CreateBy       string    `xorm:"VARCHAR(50)"` //创建人
+	ModifiedOn     time.Time `xorm:"DATETIME updated"`
+	ModifiedUserId int       `xorm:"INT(10)"`
+	ModifiedBy     string    `xorm:"VARCHAR(50)"`
+}

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

@@ -210,6 +210,7 @@ var (
 	LimsPreparationName                      string = "LimsPreparation"             //样品制备表
 	LimsCreateReportName                     string = "LimsCreateReport"            //报告生成
 	LimsDateEntryName                        string = "LimsDateEntry"               //数据录入
+	LimsDateEntryAttachName                  string = "LimsDateEntryAttach"         //数据录入附件
 	LimsDocHistoryName                       string = "LimsDocHistory"              //数据录入文档历史
 	LimsEntrustSampleName                    string = "LimsEntrustSample"           //委托样品明细表
 	LimsEntrustSampleTypeName                string = "LimsEntrustSampleType"       //详情表
@@ -255,7 +256,7 @@ var (
 	LimsReportDrillCollarName                string = "LimsReportDrillCollar"          //  石油专用管材钻铤检验记录
 	LimsPetroleUmPipeName                    string = "LimsReportPetroleumPipe"        //  石油专用管材方钻杆检验记录
 	LimsCertificateName                      string = "LimsCertificate"                //  关联证书表
-	LimsReportOilPipeUltrasonicName          string = "LimsReportOilPipeUltrasonic"   // 石油专用管材油(套)管超声波检测记录
+	LimsReportOilPipeUltrasonicName          string = "LimsReportOilPipeUltrasonic"    // 石油专用管材油(套)管超声波检测记录
 )
 
 //分页信息及数据

+ 129 - 0
src/dashoo.cn/backend/api/controllers/lims/limsdataentry.go

@@ -4830,3 +4830,132 @@ func (this *LimsDataEntryController) WordToPdf() {
 	this.Data["json"] = pdfUrl
 	this.ServeJSON()
 }
+
+// @Title 获取列表
+// @Description get user by token
+// @Success 200 {object} []annualaudit.OilAnnualAudit
+// @router /myfilelist [get]
+func (this *LimsDataEntryController) GetMyFileList() {
+
+	//获取分页信息
+	page := this.GetPageInfoForm()
+	where := " 1=1 "
+	orderby := "Id"
+	asc := false
+	Order := this.GetString("Order")
+	Prop := this.GetString("Prop")
+	if Order != "" && Prop != "" {
+		orderby = Prop
+		if Order == "asc" {
+			asc = true
+		}
+	}
+	DateEntryId := this.GetString("DateEntryId")
+	FileName := this.GetString("FileName")
+	FileType := this.GetString("FileType")
+	FileUrl := this.GetString("FileUrl")
+	Remark := this.GetString("Remark")
+	CreateOn := this.GetString("CreateOn")
+
+	if DateEntryId != "" {
+		where = where + " and DateEntryId like '%" + DateEntryId + "%'"
+	}
+
+	if FileName != "" {
+		where = where + " and FileName like '%" + FileName + "%'"
+	}
+
+	if FileType != "" {
+		where = where + " and FileType like '%" + FileType + "%'"
+	}
+
+	if FileUrl != "" {
+		where = where + " and FileUrl like '%" + FileUrl + "%'"
+	}
+
+	if Remark != "" {
+		where = where + " and Remark like '%" + Remark + "%'"
+	}
+
+	if CreateOn != "" {
+		dates := strings.Split(CreateOn, ",")
+		if len(dates) == 2 {
+			minDate := dates[0]
+			maxDate := dates[1]
+			where = where + " and CreateOn>='" + minDate + "' and CreateOn<='" + maxDate + "'"
+		}
+	}
+
+	svc := limsdataentry.GetLimsDataEntryService(utils.DBE)
+	var list []limsdataentry.LimsDateEntryAttach
+	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
+	var datainfo DataInfo
+	datainfo.Items = list
+	datainfo.CurrentItemCount = total
+	datainfo.PageIndex = page.CurrentPage
+	datainfo.ItemsPerPage = page.Size
+	this.Data["json"] = &datainfo
+	this.ServeJSON()
+}
+
+// @Title 删除单条信息
+// @Description
+// @Success 200 {object} ErrorInfo
+// @Failure 403 :id 为空
+// @router /deletemyfile/:Id [delete]
+func (this *LimsDataEntryController) DeleteFileEntity() {
+	Id := this.Ctx.Input.Param(":Id")
+	var errinfo ErrorInfo
+	if Id == "" {
+		errinfo.Message = "操作失败!请求信息不完整"
+		errinfo.Code = -2
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+		return
+	}
+	svc := limsdataentry.GetLimsDataEntryService(utils.DBE)
+	var model limsdataentry.LimsDateEntryAttach
+	var entityempty limsdataentry.LimsDateEntryAttach
+	opdesc := "删除-" + Id
+	err := svc.DeleteOperationAndWriteLogBytbl(this.User.AccCode+LimsDateEntryAttachName, BaseOperationLogName, Id, &model, &entityempty, utils.ToStr(this.User.Id), this.User.Username, opdesc, "", "附件删除")
+	if err == nil {
+		errinfo.Message = "删除成功"
+		errinfo.Code = 0
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "删除失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}
+
+// @Title 添加
+// @Description 新增
+// @Success	200	{object} controllers.Request
+// @router /adddataentryfile [post]
+func (this *LimsDataEntryController) AddDataEntryFile() {
+	svc := limsdataentry.GetLimsDataEntryService(utils.DBE)
+	var model limsdataentry.LimsDateEntryAttach
+	var jsonBlob = this.Ctx.Input.RequestBody
+	json.Unmarshal(jsonBlob, &model)
+	model.CreateOn = time.Now()
+	model.CreateBy = this.User.Realname
+	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()
+	_, err := svc.InsertEntityBytbl(this.User.AccCode+LimsDateEntryAttachName, &model)
+	var errinfo ErrorDataInfo
+	if err == nil {
+		//新增
+		errinfo.Message = "添加成功!"
+		errinfo.Code = 0
+		errinfo.Item = model.Id
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	} else {
+		errinfo.Message = "添加失败!" + utils.AlertProcess(err.Error())
+		errinfo.Code = -1
+		this.Data["json"] = &errinfo
+		this.ServeJSON()
+	}
+}

+ 185 - 64
src/dashoo.cn/frontend_web/src/components/lims/attachlist.vue

@@ -1,52 +1,29 @@
 <template>
   <div>
-    <el-tabs tabPosition="left"  v-model="activeName">
+    <el-tabs tabPosition="left" v-model="activeName">
 
       <el-tab-pane label="上传附件" name="first">
-        <el-table
-          :data="tableData"
-          stripe
-          style="width: 100%">
-          <el-table-column
-            prop="date"
-            label="上传日期"
-            width="180">
+        <el-table :data="FiletableData" stripe style="width: 100%">
+          <el-table-column prop="date" label="上传日期" width="180">
           </el-table-column>
-          <el-table-column
-            prop="name"
-            label="预览"
-            width="180">
+          <el-table-column prop="name" label="预览" width="180">
           </el-table-column>
-          <el-table-column
-            prop="address"
-            label="文件地址">
+          <el-table-column prop="address" label="文件地址">
             <template slot="header" slot-scope="scope">
-              <el-button size="mini" type="primary">上传附件</el-button>
+              <el-button size="mini" type="primary" @click="openfiledialog('1')">上传附件</el-button>
             </template>
           </el-table-column>
         </el-table>
       </el-tab-pane>
       <el-tab-pane label="问题附件" name="second">
-        <el-table
-          :data="tableData"
-          stripe
-          style="width: 100%">
-          <el-table-column
-            prop="date"
-            label="上传日期"
-            width="180">
+        <el-table :data="QuesFiletableData" stripe style="width: 100%">
+          <el-table-column prop="date" label="上传日期" width="180">
           </el-table-column>
-          <el-table-column
-            prop="name"
-            label="预览"
-            width="180">
+          <el-table-column prop="name" label="预览" width="180">
           </el-table-column>
-          <el-table-column
-            prop="address"
-            label="文件地址">
+          <el-table-column prop="address" label="文件地址">
             <template slot="header" slot-scope="scope">
-              <!--<el-button size="mini" type="primary">点击上传</el-button>-->
-              <el-button size="mini" type="primary" @click="datadialogVisible=true">上传问题附件</el-button>
+              <el-button size="mini" type="primary" @click="openfiledialog('2')">上传问题附件</el-button>
             </template>
           </el-table-column>
         </el-table>
@@ -54,7 +31,7 @@
     </el-tabs>
 
     <!--新增、编辑附件信息-->
-    <el-dialog title="附件信息" :visible.sync="datadialogVisible" top="5vh">
+    <el-dialog :title="dialogtiltle" :visible.sync="datadialogVisible" top="5vh">
       <el-form :model="attachForm" ref="templateform">
         <el-form-item label="模板类型" label-width="120px">
           <el-select v-model="attachForm.Type" style="width:100%" disabled>
@@ -70,13 +47,9 @@
           <el-input type="textarea" v-model="attachForm.Remark" placeholder="请输入附件说明"></el-input>
         </el-form-item>
 
-        <el-form-item label="附件地址" prop="FileURL" label-width="120px">
-          <el-input v-model="attachForm.FileURL" placeholder="请输入附件地址"></el-input>
-        </el-form-item>
-
         <el-form-item label="附件上传" prop="TemplateInfo" label-width="120px">
-          <el-upload :multiple = "false" action="" :limit="1" ref="refuploadattach"
-                     :http-request="uploadrequest" class="attach-uploader" :show-file-list="true" :before-upload="beforeAvatarUpload">
+          <el-upload multiple style="margin-top: 10px;" action="" ref="refuploadattach" :http-request="uploadrequest"
+                class="attach-uploader" :before-upload="beforeAvatarUpload">
             <i class="el-icon-upload attach-uploader-icon"></i>
           </el-upload>
         </el-form-item>
@@ -92,41 +65,127 @@
 </template>
 
 <script>
+  import {
+    mapGetters
+  } from 'vuex'
+  import axios from 'axios'
+  import uploadajax from '@/assets/js/uploadajax.js'
   export default {
-    data () {
+    computed: {
+      ...mapGetters({
+        authUser: 'authUser'
+      })
+    },
+    name: 'attchlist',
+    props: {
+      DataEntryId: {
+        type: String,
+        default: '0'
+      }
+    },
+
+    data() {
       return {
+        dialogtiltle: "",
         service_flag: 'add',
         datadialogVisible: false,
         activeName: 'first',
         attachForm: {
+          DataEntryId: '',
           Id: 0,
           Name: '',
           Remark: '',
           FileURL: '',
           Type: '1',
-
+          CreatOn: '',
+        },
+        //分页参数
+        size: 10,
+        currentPage: 1,
+        currentItemCount: 0,
+        //列表排序
+        Column: {
+          Order: '',
+          Prop: ''
         },
-        tableData: [{
-          date: '2016-05-02',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1518 弄'
-        }, {
-          date: '2016-05-04',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1517 弄'
-        }, {
-          date: '2016-05-01',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1519 弄'
-        }, {
-          date: '2016-05-03',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1516 弄'
-        }]
+        // 查询时间
+        CreateOn: [new Date(new Date().getTime() - 30 * 24 * 60 * 60 * 1000), new Date()],
+        searchform: {
+          DataEntryId: '',
+          Id: 0,
+          Name: '',
+          Remark: '',
+          FileURL: '',
+          Type: '1',
+          CreatOn: '',
+        },
+        QuesFiletableData: [],
+        FiletableData: [],
+        waituploads: []   // 等待上传的附件列表
       }
     },
-    method: {
-      uploadrequest (option) {
+    created() {
+      this.initDatas()
+    },
+
+    methods: {
+      initDatas() {
+        let _this = this;
+        let MyCreateOn = []
+        if (!_this.CreateOn) {
+          _this.CreateOn = []
+        }
+        // 解析时间
+        if (_this.CreateOn.length == 2) {
+          _this.CreateOn[1].setHours(23)
+          _this.CreateOn[1].setMinutes(59)
+          _this.CreateOn[1].setSeconds(59)
+          MyCreateOn.push(_this.formatDateTime(_this.CreateOn[0]))
+          MyCreateOn.push(_this.formatDateTime(_this.CreateOn[1]))
+        }
+        let params = {
+          _currentPage: this.currentPage,
+          _size: this.size,
+          Order: this.Column.Order,
+          Prop: this.Column.Prop
+        }
+        this.searchform.DataEntryId = this.DataEntryId
+        Object.assign(params, this.searchform)
+        this.$axios.get('/limsdataentry/myfilelist?CreateOn=' + MyCreateOn.join(','), {
+            params
+          })
+          .then(function (response) {
+            _this.FiletableData = response.data.items
+            _this.currentItemCount = response.data.currentItemCount
+          })
+          .catch(function (error) {
+            console.log(error);
+          });
+      },
+      makesure() {
+          if (this.$refs.refuploadattach.uploadFiles && this.$refs.refuploadattach.uploadFiles.length > 0) {
+            // 上传附件是否完成判断
+            if (!this.attachissuccess()) {
+              this.$message.error('有附件未成功上传!不能保存数据')
+              return
+            }
+            this.getattachissuccess()
+            this.editSubfile()
+          } else {
+            this.editSubfile()
+          }
+      },
+      //打开附件上传弹窗
+      openfiledialog(val) {
+        if (val === '1') {
+          this.dialogtiltle = "附件上传"
+          this.datadialogVisible = true
+        } else if (val === '2') {
+          this.dialogtiltle = "问题附件上传"
+          this.datadialogVisible = true
+        }
+      },
+      uploadrequest(option) {
         let _this = this
         this.$axios.post(process.env.upfilehost, {})
           .then(function (res) {
@@ -163,17 +222,79 @@
         }
         return true
       },
+      // 判断附件是否上传成功
+      attachissuccess() {
+        if (this.$refs.refuploadattach.uploadFiles && this.$refs.refuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.refuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.refuploadattach.uploadFiles[i].status !== 'success') {
+              return false
+            }
+          }
+        }
+        return true
+      },
+      getattachissuccess() {
+        this.SubfileForm.FileUrl = ''
+        if (this.$refs.refuploadattach.uploadFiles && this.$refs.refuploadattach.uploadFiles.length > 0) {
+          for (let i = 0; i < this.$refs.refuploadattach.uploadFiles.length; i++) {
+            if (this.$refs.refuploadattach.uploadFiles[i].status === 'success') {
+              for (let j = 0; j < this.waituploads.length; j++) {
+                if (this.waituploads[j].uid === this.$refs.refuploadattach.uploadFiles[i].uid) {
+                  this.SubfileForm.FileUrl +=
+                    `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.refuploadattach.uploadFiles[i].name}$`
+                  this.SubfileForm.FileName += `${this.$refs.refuploadattach.uploadFiles[i].name}$`
+                }
+              }
+            }
+          }
+        }
+      },
+      clickachment(url, uid) {
+        window.open(`http://${url}`)
+      },
+
+
+      formatDateTime(date) {
+        var y = date.getFullYear()
+        var m = date.getMonth() + 1
+        m = m < 10 ? ('0' + m) : m
+        var d = date.getDate()
+        d = d < 10 ? ('0' + d) : d
+        var h = date.getHours()
+        var minute = date.getMinutes()
+        minute = minute < 10 ? ('0' + minute) : minute
+        return y + '-' + m + '-' + d + ' ' + h + ':' + minute
+      },
 
     }
   }
+
 </script>
 
 <style>
-  .attach-uploader .el-upload {
+   .attach-uploader .el-upload {
     border: 1px dashed #63B8FF;
     cursor: pointer;
     position: relative;
     overflow: hidden;
-    margin-bottom: -20px;
+    margin-left: 20px
+  }
+
+  .attach-uploader .el-upload:hover {
+    border-color: #228B22;
   }
+
+  .attach-uploader-icon {
+    font-size: 25px;
+    color: #63B8FF;
+    width: 50px;
+    height: 50px;
+    line-height: 50px;
+    text-align: center;
+  }
+
+  .attach-uploader-icon:hover {
+    color: #228B22;
+  }
+
 </style>

+ 1 - 1
src/dashoo.cn/frontend_web/src/pages/lims/reportatmosvalve/subdata/datamain.vue

@@ -140,7 +140,7 @@
         <template slot="title">
           <i class="el-icon-upload"></i> 附件列表
         </template>
-        <attach-list></attach-list>
+      <attach-list :DataEntryId="DataEntryId+''"></attach-list>
       </el-collapse-item>
     </el-collapse>
   </no-ssr>