From 32a95699e59c5c65e18c08643266c9cbfa380ee4 Mon Sep 17 00:00:00 2001 From: licp <lichunping@guanfang.com.cn> Date: 星期五, 07 六月 2024 09:56:05 +0800 Subject: [PATCH] 优化设备明细、检验任务附件权限 --- src/components/view/a5-laboratory-management.vue | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 229 insertions(+), 2 deletions(-) diff --git a/src/components/view/a5-laboratory-management.vue b/src/components/view/a5-laboratory-management.vue index b37f44b..8a3ad69 100644 --- a/src/components/view/a5-laboratory-management.vue +++ b/src/components/view/a5-laboratory-management.vue @@ -34,6 +34,35 @@ height: calc(100% - 60px - 80px - 10px - 40px); padding: 20px; } + .el-upload { + border: 1px dashed #d9d9d9; + border-radius: 6px; + cursor: pointer; + position: relative; + overflow: hidden; + } + .el-upload:hover { + border-color: #409EFF; + } + .avatar-uploader-icon { + border: 1px dashed #d9d9d9; + font-size: 28px; + color: #8c939d; + width: 120px; + height: 120px; + line-height: 120px; + text-align: center; + } + .avatar { + width: 120px; + height: 120px; + display: block; + } + .btns{ + position: absolute; + right: 80px; + top: 13px; + } </style> <template> @@ -67,6 +96,51 @@ :upUrl="$api.laboratoryScope.upParameter" :delUrl="$api.laboratoryScope.delParameter" :componentData="componentData" :key="upIndex" /> </div> + <el-dialog title="鍗扮珷绠$悊" :visible.sync="fileVisible" width="60vw"> + <div class="btns"> + <el-button size="medium" type="primary" @click="openUpload">鏇存柊鍗扮珷</el-button> + </div> + <ValueTable ref="ValueTable0" :url="$api.sealScope.selectSeal" + :componentData="fileComponentData" :key="upIndex" style="height: 400px;" /> + </el-dialog> + <el-dialog title="鏇存柊鍗扮珷" :visible.sync="upFileVisible" width="400px"> + <div class="search_thing" style="margin-bottom: 16px;"> + <div class="search_label" style="width:90px">鍗扮珷绫诲瀷锛�</div> + <div class="search_input"> + <el-cascader + v-model="dataForm.type" + :options="options" + :show-all-levels="false" + :props="props" + placeholder="璇烽�夋嫨" size="small" + style="width:100%" + collapse-tags + clearable></el-cascader> + </div> + </div> + <div class="search_thing"> + <div class="search_label" style="width:90px">鍗扮珷鍥剧墖锛�</div> + <div class="search_input"> + <el-upload + :action="action" + :headers="headers" + accept='image/jpg,image/jpeg,image/png' + :show-file-list="false" + :on-success="handleSuccess" + :on-change="beforeUpload" + ref="upload" + :on-error="onError" + > + <img v-if="dataForm.address" :src="javaApi+'/img/'+dataForm.address" style="width: 110px;height: 110px;" > + <i v-else class="el-icon-plus avatar-uploader-icon"></i> + </el-upload> + </div> + </div> + <span slot="footer" class="dialog-footer"> + <el-button @click="upFileVisible = false">鍙� 娑�</el-button> + <el-button type="primary" @click="confirmConnect" :loading="loading">纭� 瀹�</el-button> + </span> + </el-dialog> </div> </template> @@ -75,6 +149,16 @@ export default { components: { ValueTable + }, + computed: { + headers() { + return { + 'token': sessionStorage.getItem('token') + } + }, + action() { + return this.javaApi + this.$api.deviceScope.uploadFile + } }, data() { return { @@ -102,26 +186,106 @@ font: '鍒犻櫎', type: 'text', method: 'doDiy' + }, { + id: '', + font: '鍗扮珷绠$悊', + type: 'text', + method: 'fileManagement' }], - tagField: {}, + tagField: { + type:{ + select:[] + } + }, selectField: {}, requiredAdd: ['laboratoryName', 'laboratoryNumber', 'head', 'phoneNumber'], requiredUp: ['laboratoryName', 'laboratoryNumber', 'head', 'phoneNumber'] }, + fileComponentData: { + entity: { + labId:null, + orderBy: { + field: 'id', + order: 'asc' + } + }, + isPage:false, + init:false, + isIndex: true, + showSelect: false, + select: false, + do: [], + tagField: {}, + selectField: { + type:{ + select:[] + } + }, + requiredAdd: [], + requiredUp: [], + addUpload:['address'], + }, entityCopy: {}, upIndex: 0, addDia: true, - addPower: true + addPower: true, + fileVisible:false, + upFileVisible:false, + loading:false, + dataForm:{ + type:'', + address:'', + }, + props: { multiple: false,emitPath:false,}, + options:[ + { + value:'瀹為獙瀹よ祫璐�', + label:'瀹為獙瀹よ祫璐�', + children:[] + }, + { + value:'鎶ュ憡绫诲瀷', + label:'鎶ュ憡绫诲瀷', + children:null + }, + ], } }, mounted() { this.entityCopy = this.HaveJson(this.componentData.entity) this.getPower() + this.getCertificationDetail() }, methods: { refreshTable() { this.$refs['ValueTable'].selectList() }, + getCertificationDetail(){ + this.$axios.post(this.$api.certification.getCertificationDetail, { + page: { + current: -1, + size: -1, + }, + entity: { + name: null, + } + }, { + headers: { + 'Content-Type': 'application/json' + } + }).then(res => { + if (res.code === 201) { + return + } + let arr = res.data.body.records.map(m=>{ + m.value = m.name; + m.label = m.name; + return m + }) + this.options[0].children = arr; + this.fileComponentData.selectField.type.select = arr; + }) + }, refresh() { this.componentData.entity = this.HaveJson(this.entityCopy) this.upIndex++ @@ -129,12 +293,69 @@ openAdd() { this.$refs.ValueTable.openAddDia(this.$api.laboratoryScope.addParameter); }, + openUpload(){ + this.dataForm.type = ''; + this.dataForm.address = ''; + this.upFileVisible = true; + }, + fileManagement(row){ + this.fileVisible = true; + this.fileComponentData.entity.labId = row.id; + this.$nextTick(function () { + this.$refs['ValueTable0'].selectList() + }) + }, + confirmConnect(){ + if(!this.dataForm.type){ + this.$message.error('鏈笂閫夋嫨鍗扮珷绫诲瀷'); + return + } + if(!this.dataForm.address){ + this.$message.error('鏈笂浼犲嵃绔�'); + return + } + this.loading = true; + this.$axios.post(this.$api.sealScope.addSeal, { + labId:this.fileComponentData.entity.labId, + ...this.dataForm + }, { + headers: { + 'Content-Type': 'application/json' + } + }).then(res => { + this.loading = false; + if (res.code === 201) { + return + } + this.$refs['ValueTable0'].selectList() + this.upFileVisible = false; + }) + }, + handleSuccess(response,){ + if (response.code == 200) { + this.dataForm.address = response.data.url + } + }, + beforeUpload(file,type) { + if (file.size > 1024 * 1024 * 10) { + this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M'); + this.$refs.upload.clearFiles() + return false; + } else { + return true; + } + }, + onError(err, file, fileList,type) { + this.$message.error('涓婁紶澶辫触') + this.$refs.upload.clearFiles() + }, // 鏉冮檺鍒嗛厤 getPower(radio) { let power = JSON.parse(sessionStorage.getItem('power')) let up = false let del = false let add = false + let file = false for (var i = 0; i < power.length; i++) { if (power[i].menuMethod == 'upParameter') { up = true @@ -145,6 +366,12 @@ if (power[i].menuMethod == 'addParameter') { add = true } + if (power[i].menuMethod == 'addSeal') { + file = true + } + } + if (!file) { + this.componentData.do.splice(2, 1) } if (!del) { this.componentData.do.splice(1, 1) -- Gitblit v1.9.3