3
2
Ver Fonte

附件列表上传

huahaiyan há 6 anos atrás
pai
commit
9de5be2c44

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

@@ -487,7 +487,7 @@ type UserModel struct {
 
 //数据录入附件
 type LimsDateEntryAttach struct {
-	Id             int       `xorm:"not null pk autoincr INT(10)"`
+	Id             int       `xorm:"<- not null pk autoincr INT(50)"`
 	FileUrl        string    `xorm:"VARCHAR(255)"`
 	FileName       string    `xorm:VARCHAR(50)`
 	DateEntryId    int       `xorm:"INT(10)"`

+ 8 - 35
src/dashoo.cn/backend/api/controllers/lims/limsdataentry.go

@@ -4834,9 +4834,9 @@ func (this *LimsDataEntryController) WordToPdf() {
 // @Title 获取列表
 // @Description get user by token
 // @Success 200 {object} []annualaudit.OilAnnualAudit
-// @router /myfilelist [get]
+// @router /myfilelist/:Id [get]
 func (this *LimsDataEntryController) GetMyFileList() {
-
+	DataEntryId := this.Ctx.Input.Param(":Id")
 	//获取分页信息
 	page := this.GetPageInfoForm()
 	where := " 1=1 "
@@ -4850,42 +4850,13 @@ func (this *LimsDataEntryController) GetMyFileList() {
 			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 DataEntryId != "" {
+		where = where + " and DateEntryId = " + DataEntryId
 	}
-
 	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 + "'"
-		}
+		where = where + " and FileType = " + FileType
 	}
-
 	svc := limsdataentry.GetLimsDataEntryService(utils.DBE)
 	var list []limsdataentry.LimsDateEntryAttach
 	total := svc.GetPagingEntitiesWithOrderBytbl(this.User.AccCode, page.CurrentPage, page.Size, orderby, asc, &list, where)
@@ -4934,12 +4905,14 @@ func (this *LimsDataEntryController) DeleteFileEntity() {
 // @Title 添加
 // @Description 新增
 // @Success	200	{object} controllers.Request
-// @router /adddataentryfile [post]
+// @router /adddataentryfile/:id [post]
 func (this *LimsDataEntryController) AddDataEntryFile() {
+	DataEntryId := this.Ctx.Input.Param(":id")
 	svc := limsdataentry.GetLimsDataEntryService(utils.DBE)
 	var model limsdataentry.LimsDateEntryAttach
 	var jsonBlob = this.Ctx.Input.RequestBody
 	json.Unmarshal(jsonBlob, &model)
+	model.DateEntryId,_ = strconv.Atoi(DataEntryId)
 	model.CreateOn = time.Now()
 	model.CreateBy = this.User.Realname
 	model.CreateUserId, _ = utils.StrTo(this.User.Id).Int()

+ 139 - 75
src/dashoo.cn/frontend_web/src/components/lims/attachlist.vue

@@ -1,29 +1,48 @@
 <template>
   <div>
-    <el-tabs tabPosition="left" v-model="activeName">
+    <el-tabs tabPosition="left" v-model="activeName"  @tab-click="handleClick">
 
       <el-tab-pane label="上传附件" name="first">
-        <el-table :data="FiletableData" stripe style="width: 100%">
-          <el-table-column prop="date" label="上传日期" width="180">
+        <el-table :data="FiletableData" stripe style="width: 100%" class="mytable">
+          <el-table-column prop="CreateOn" label="上传日期" width="180">
+            <template slot-scope="scope">
+                {{ jstimehandle(scope.row.CreateOn+'') }}
+              </template>
           </el-table-column>
-          <el-table-column prop="name" label="预览" width="180">
+          <el-table-column prop="FileName" label="预览" width="180">
+            <template slot-scope="scope">
+            <a :href="scope.row.FileUrl" target="_blank" class="buttonText">{{scope.row.FileName}}</a>
+          </template>
           </el-table-column>
           <el-table-column prop="address" label="文件地址">
             <template slot="header" slot-scope="scope">
-              <el-button size="mini" type="primary" @click="openfiledialog('1')">上传附件</el-button>
+              <el-upload action="" multiple ref="refuploadattach" :http-request="uploadrequest" :on-success="uploadfile"
+                :before-upload="beforeAvatarUpload" :show-file-list="false">
+                <el-button size="mini" type="primary">上传附件</el-button>
+              </el-upload>
             </template>
           </el-table-column>
         </el-table>
       </el-tab-pane>
       <el-tab-pane label="问题附件" name="second">
-        <el-table :data="QuesFiletableData" stripe style="width: 100%">
-          <el-table-column prop="date" label="上传日期" width="180">
+        <el-table :data="QueFiletableData" stripe style="width: 100%" class="mytable">
+          <el-table-column prop="CreateOn" label="上传日期" width="180">
+            <template slot-scope="scope">
+                {{ jstimehandle(scope.row.CreateOn+'') }}
+              </template>
           </el-table-column>
-          <el-table-column prop="name" label="预览" width="180">
+          <el-table-column prop="FileName" label="预览" width="180">
+             <template slot-scope="scope">
+            <a :href="scope.row.FileUrl" target="_blank" class="buttonText">{{scope.row.FileName}}</a>
+          </template>
           </el-table-column>
           <el-table-column prop="address" label="文件地址">
             <template slot="header" slot-scope="scope">
-              <el-button size="mini" type="primary" @click="openfiledialog('2')">上传问题附件</el-button>
+              <el-upload action="" multiple ref="refuploadattach" :http-request="uploadrequest"
+                :before-upload="beforeAvatarUpload" :on-success="uploadquefile" :show-file-list="false">
+                <el-button size="mini" type="primary">上传问题附件</el-button>
+              </el-upload>
+              <!-- <el-button size="mini" type="primary" @click="openfiledialog('2')">上传问题附件</el-button> -->
             </template>
           </el-table-column>
         </el-table>
@@ -33,14 +52,14 @@
     <!--新增、编辑附件信息-->
     <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>
+        <el-form-item label="附件类型" label-width="120px">
+          <el-select v-model="attachForm.FileType" style="width:100%" disabled>
             <el-option label="附件" value="1"></el-option>
             <el-option label="问题附件" value="2"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="附件名称" prop="Name" label-width="120px">
-          <el-input v-model="attachForm.Name" auto-complete="off" placeholder="请输入附件名称"></el-input>
+        <el-form-item label="附件名称" prop="FileName" label-width="120px">
+          <el-input v-model="attachForm.FileName" auto-complete="off" placeholder="请输入附件名称"></el-input>
         </el-form-item>
 
         <el-form-item label="附件说明" label-width="120px">
@@ -49,7 +68,7 @@
 
         <el-form-item label="附件上传" prop="TemplateInfo" label-width="120px">
           <el-upload multiple style="margin-top: 10px;" action="" ref="refuploadattach" :http-request="uploadrequest"
-                class="attach-uploader" :before-upload="beforeAvatarUpload">
+            class="attach-uploader" :before-upload="beforeAvatarUpload">
             <i class="el-icon-upload attach-uploader-icon"></i>
           </el-upload>
         </el-form-item>
@@ -93,11 +112,9 @@
         attachForm: {
           DataEntryId: '',
           Id: 0,
-          Name: '',
-          Remark: '',
-          FileURL: '',
-          Type: '1',
-          CreatOn: '',
+          FileName: '',
+          FileUrl: '',
+          FileType: '1',
         },
         //分页参数
         size: 10,
@@ -113,45 +130,44 @@
         searchform: {
           DataEntryId: '',
           Id: 0,
-          Name: '',
+          FileName: '',
           Remark: '',
-          FileURL: '',
-          Type: '1',
+          FileUrl: '',
+          FileType: '1',
           CreatOn: '',
         },
         QuesFiletableData: [],
         FiletableData: [],
-        waituploads: []   // 等待上传的附件列表
+        QueFiletableData: [],
+        uploadingfile: {} // 等待上传的附件列表
       }
     },
     created() {
       this.initDatas()
+      this.initDatasQue()
     },
 
     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]))
+      handleClick(tab,event) {
+        if (tab.name === "first"){
+          this.initDatas()
+        }else if (tab.name === "second"){
+          this.initDatasQue()
         }
+      },
+      initDatas() {
+        let _this = this
         let params = {
           _currentPage: this.currentPage,
           _size: this.size,
           Order: this.Column.Order,
           Prop: this.Column.Prop
         }
+        this.searchform.FileType = 1
         this.searchform.DataEntryId = this.DataEntryId
         Object.assign(params, this.searchform)
-        this.$axios.get('/limsdataentry/myfilelist?CreateOn=' + MyCreateOn.join(','), {
+        console.log("----333--",params)
+        this.$axios.get('/limsdataentry/myfilelist/'+this.DataEntryId, {
             params
           })
           .then(function (response) {
@@ -162,18 +178,70 @@
             console.log(error);
           });
       },
-      makesure() {
-          if (this.$refs.refuploadattach.uploadFiles && this.$refs.refuploadattach.uploadFiles.length > 0) {
-            // 上传附件是否完成判断
-            if (!this.attachissuccess()) {
-              this.$message.error('有附件未成功上传!不能保存数据')
-              return
+      initDatasQue() {
+        let _this = this
+        let params = {
+          _currentPage: this.currentPage,
+          _size: this.size,
+          Order: this.Column.Order,
+          Prop: this.Column.Prop
+        }
+        this.searchform.FileType = 2
+        this.searchform.DataEntryId = this.DataEntryId
+        this.searchform
+        Object.assign(params, this.searchform)
+        console.log("----333--",params)
+        this.$axios.get('/limsdataentry/myfilelist/'+this.DataEntryId, {
+            params
+          })
+          .then(function (response) {
+            _this.QueFiletableData = response.data.items
+            _this.currentItemCount = response.data.currentItemCount
+          })
+          .catch(function (error) {
+            console.log(error);
+          });
+      },
+      //上传文件
+      uploadfile(res, file) {
+        this.attachForm.FileUrl = "http://" + `${this.uploadingfile.url}/${this.uploadingfile.fid}`
+        this.attachForm.FileName = res.name
+        this.attachForm.DataEntryId = parseInt(this.DataEntryId)
+        this.attachForm.FileType = 1
+        console.log("------",this.attachForm)
+        this.addfile()
+      },
+      uploadquefile(res, file) {
+        this.attachForm.FileUrl = "http://" + `${this.uploadingfile.url}/${this.uploadingfile.fid}`
+        this.attachForm.FileName = res.name
+        this.attachForm.DataEntryId = parseInt(this.DataEntryId)
+        this.attachForm.FileType = 2
+        this.addfile()
+      },
+      addfile() {
+        let params = this.attachForm
+        console.log("params", params)
+        this.$axios.post('/limsdataentry/adddataentryfile/' + this.DataEntryId, params)
+          .then(res => {
+            //this.attachForm.Id = res.data.item
+            if (res.data.code === 0) {
+              this.$message({
+                type: 'success',
+                message: res.data.message,
+              })
+              this.initDatas()
+              this.initDatasQue()
+              this.$refs.refuploadattach.uploadFiles = []
+            } else {
+              this.$message({
+                type: 'warning',
+                message: res.data.message
+              })
             }
-            this.getattachissuccess()
-            this.editSubfile()
-          } else {
-            this.editSubfile()
-          }
+          })
+          .catch(err => {
+            console.error(err)
+          })
       },
       //打开附件上传弹窗
       openfiledialog(val) {
@@ -187,15 +255,15 @@
       },
       uploadrequest(option) {
         let _this = this
-        this.$axios.post(process.env.upfilehost, {})
+        axios.post(process.env.upfilehost, {})
           .then(function (res) {
             if (res.data && res.data.fid && res.data.fid !== '') {
               option.action = `http://${res.data.url}/${res.data.fid}`
-              _this.waituploads.push({
+              _this.uploadingfile = {
                 uid: option.file.uid,
                 url: res.data.publicUrl,
                 fid: res.data.fid
-              })
+              }
               uploadajax(option)
             } else {
               _this.$message({
@@ -234,15 +302,15 @@
         return true
       },
       getattachissuccess() {
-        this.SubfileForm.FileUrl = ''
+        this.attachForm.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.attachForm.FileUrl +=
                     `${this.waituploads[j].url}/${this.waituploads[j].fid}|${this.$refs.refuploadattach.uploadFiles[i].name}$`
-                  this.SubfileForm.FileName += `${this.$refs.refuploadattach.uploadFiles[i].name}$`
+                  this.attachForm.FileName += `${this.$refs.refuploadattach.uploadFiles[i].name}$`
                 }
               }
             }
@@ -253,6 +321,19 @@
         window.open(`http://${url}`)
       },
 
+      jstimehandle(val) {
+        if (val === '') {
+          return '----'
+        } else if (val === '0001-01-01T08:00:00+08:00') {
+          return '----'
+        } else if (val === '5000-01-01T23:59:59+08:00') {
+          return '永久'
+        } else {
+          val = val.replace('T', ' ')
+          return val.substring(0, 10)
+        }
+      },
+
 
       formatDateTime(date) {
         var y = date.getFullYear()
@@ -272,29 +353,12 @@
 </script>
 
 <style>
-   .attach-uploader .el-upload {
-    border: 1px dashed #63B8FF;
-    cursor: pointer;
-    position: relative;
-    overflow: hidden;
-    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;
+  .mytable th {
+    padding: 15px 0 !important;
   }
 
-  .attach-uploader-icon:hover {
-    color: #228B22;
+  .mytable td {
+    padding: 15px 0 !important;
   }
 
 </style>