Commit 972ce9ef authored by 李苏's avatar 李苏 💬

附件相关调整

parent 97b3b8ca
<template>
<RelDialog width="50%" :type='type' :editApp='editApp' :app='app' :buttonApp='buttonApp'>
<RelDialog :attachments='attachments' width="50%" :type='type' :editApp='editApp' :app='app' @getForm='getForm' :buttonApp='buttonApp'>
<el-form slot="form" ref="form" :model="form" label-width="100px" :rules="rules">
<el-row :gutter="20" :app="this">
<EditColItem :required="item.required||false" :readonly="item.readonly?true:false "
v-for="(item,index) in editColItemList " :value="item.value" :span="item.span" :label="item.label"
:prop='item.prop' :key="item.prop" :type="item.type" :typeConfig='item.typeConfig' :rule="item.rule" />
</el-row>
<!-- 附件数据-->
<el-row v-if="type!='view'" :gutter="20">
<el-form-item label="图片">
<el-upload ref="upload" :headers='{
Gtoken
}' :action="`${baseurl}/attachment/upload/tmp`" list-type="picture-card"
:on-preview="handlePictureCardPreview" :on-success='success' :on-remove="handleRemove" :data="{
groupid:'',
folder:'uywsjlr'
}">
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-row>
<el-row v-if="showList.length!=0">
<el-form-item label="已上传附件">
<div class="demo-image">
<div style="display: inline-block;" v-for="(item,index) in showList" :key="item.id">
<div>
<el-image :preview-src-list="showList.map(item=>item.url)"
style="width: 146.22px; height: 146.22px;margin-right: 10px;" :src="item.url" fit="fill">
</el-image>
<div v-show="type=='edit'" @click='delfile(item.id,index)'
style="width: 146.22px;line-height: 15px;font-size: 13px;color: red;text-align: center;cursor: pointer;">
删除</div>
</div>
</div>
</div>
</el-form-item>
</el-row>
<!-- 分割-->
</el-form>
</RelDialog>
</template>
<script>
import {
autoAttachDownload
} from "common/src/api/system/dmgSystem.js";
const baseurl = process.env.VUE_APP_BASE_API
const Gtoken = localStorage.getItem('Gtoken')
import {
editMixin
} from 'common'
export default {
mixins: [editMixin],
computed:{
attachments(){
let attachments=[]
this.attachmentList.forEach(item=>{
attachments.push({
id:item
})
})
this.showList.forEach(item=>{
attachments.push({
id:item.id
})
})
return attachments
}
},
data() {
return {
attachmentList:[],
showList:[],
baseurl: baseurl,
Gtoken: Gtoken,
editColItemList: [
{
......@@ -94,6 +154,78 @@
]
}
},
methods:{
handleRemove(file, fileList) {
let attachmentList = []
fileList.forEach(item => {
if (item.status == 'success') {
attachmentList.push(item.response.data.records.id)
}
})
this.attachmentList = attachmentList
console.log(this.attachmentList)
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
success(res, file, fileList) {
if (res.success) {
this.$success('上传成功')
/* 成功后同步fileList数据到form表单*/
let attachmentList = []
fileList.forEach(item => {
if (item.status == 'success') {
attachmentList.push(item.response.data.records.id)
}
})
this.attachmentList = attachmentList
} else {
const delIndex = fileList.findIndex(item => item.uid === file.uid);
if (delIndex !== -1) {
fileList.splice(delIndex, 1);
this.$error(res.message || '未知错误');
}
}
},
delfile(id, index) {
this.$confirm('是否继续该操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(res => {
this.showList.splice(index, 1)
})
},
getForm(data) {
this.$post('jyfggl/ujyfk/attachment/list', {
groupid: data.id,
}).then(res => {
res.data.records.forEach(item => {
autoAttachDownload({}, 'jyfggl/ujyfk', item.id).then(res => {
let blob = new Blob([res], {
type: 'application/' + item.type + ';charset=UTF-8',
});
let url = URL.createObjectURL(blob)
let uitem = {
url,
id: item.id
}
this.showList.push(uitem)
})
})
})
},
}
}
</script>
......@@ -5,7 +5,7 @@
</template>
<template #toolbar="ctx">
<!-- 嵌入默认页面工具栏的插槽 ctx.pagePage来操作默认页面 -->
<AttachFileShow :app='ctx.basePage'></AttachFileShow>
<!-- <AttachFileShow :app='ctx.basePage'></AttachFileShow> -->
</template>
</BasePage>
......
......@@ -54,6 +54,7 @@
} from 'common'
export default {
mixins: [editMixin],
data() {
return {
attachmentList:[],
......
......@@ -7,6 +7,34 @@
v-for="(item,index) in editColItemList " :value="item.value" :span="item.span" :label="item.label"
:prop='item.prop' :key="item.prop" :type="item.type" :typeConfig='item.typeConfig' :rule="item.rule" />
</el-row>
<el-row :gutter="20">
<el-form-item label="图片">
<el-upload :on-change='change' ref="upload" action='attachment/upload/tmp' :auto-upload='false' list-type="picture-card"
:on-remove="handleRemove" >
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-row>
<el-row >
<el-form-item label="已上传附件">
<div class="demo-image">
<div style="display: inline-block;" v-for="(item,index) in form.photo" :key="item.id">
<div>
<el-image :preview-src-list="form.photo.map(item=>item)"
style="width: 146.22px; height: 146.22px;margin-right: 10px;" :src="item" fit="fill">
</el-image>
<div v-show="type=='edit'" @click='delfile(index)'
style="width: 146.22px;line-height: 15px;font-size: 13px;color: red;text-align: center;cursor: pointer;">
删除</div>
</div>
</div>
</div>
</el-form-item>
</el-row>
</el-form>
<div slot="reFooter" class="refooter">
<span slot="footer" class="dialog-footer">
......@@ -38,6 +66,7 @@
},
data() {
return {
fileList:[],
readonly: false,
editColItemList: [
{
......@@ -76,13 +105,55 @@
}
},
methods: {
delfile(index){
this.form.splice(index,1)
},
changeBase64(file,base64List){
const reader = new FileReader();
// 读取文件内容,并在读取完成后调用 onload 事件处理函数
reader.onload = function(event) {
// event.target.result 包含了文件的 Base64 编码字符串
const base64String = event.target.result;
base64List.push(base64String)
// 你可以在这里使用 base64String,例如发送到服务器或显示在页面上
};
// 读取文件为 Data URL(Base64 编码)
return reader.readAsDataURL(file)
},
change(file, fileList){
this.fileList=fileList
},
handleRemove(file, fileList){
this.fileList=fileList
},
save() {
this.$refs['form'].validate((valid) => {
if (valid) {
let base64List=[]
this.fileList.map(item=>this.changeBase64(item.raw,base64List))
setTimeout(()=>{
if(this.rtype=='update'){
/* 其他情况*/
let oldBase64List=this.form.photo||[]
let fin=[...oldBase64List,...base64List]
this.form.photo=fin
this.app.showDialog = false
}else{
/* 新增这时候*/
this.form.photo=base64List
this.$emit('save', this.form)
}
})
},1500)
}
})
}
}
}
......
......@@ -7,6 +7,31 @@
v-for="(item,index) in editColItemList " :value="item.value" :span="item.span" :label="item.label"
:prop='item.prop' :key="item.prop" :type="item.type" :typeConfig='item.typeConfig' :rule="item.rule" />
</el-row>
<el-row :gutter="20">
<el-form-item label="图片">
<el-upload :on-change='change' ref="upload" action='attachment/upload/tmp' :auto-upload='false' list-type="picture-card"
:on-remove="handleRemove" >
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-row>
<el-row >
<el-form-item label="已上传附件">
<div class="demo-image">
<div style="display: inline-block;" v-for="(item,index) in form.photo" :key="item.id">
<div>
<el-image :preview-src-list="form.photo.map(item=>item)"
style="width: 146.22px; height: 146.22px;margin-right: 10px;" :src="item" fit="fill">
</el-image>
<div v-show="type=='edit'" @click='delfile(index)'
style="width: 146.22px;line-height: 15px;font-size: 13px;color: red;text-align: center;cursor: pointer;">
删除</div>
</div>
</div>
</div>
</el-form-item>
</el-row>
</el-form>
<div slot="reFooter" class="refooter">
<span slot="footer" class="dialog-footer">
......@@ -38,6 +63,9 @@
},
data() {
return {
fileList:[],
attachmentList:[],
showList:[],
readonly: false,
editColItemList: [
{
......@@ -76,10 +104,56 @@
}
},
methods: {
delfile(index){
this.form.splice(index,1)
},
changeBase64(file,base64List){
const reader = new FileReader();
// 读取文件内容,并在读取完成后调用 onload 事件处理函数
reader.onload = function(event) {
// event.target.result 包含了文件的 Base64 编码字符串
const base64String = event.target.result;
base64List.push(base64String)
// 你可以在这里使用 base64String,例如发送到服务器或显示在页面上
};
// 读取文件为 Data URL(Base64 编码)
return reader.readAsDataURL(file)
},
change(file, fileList){
this.fileList=fileList
},
handleRemove(file, fileList){
this.fileList=fileList
},
save() {
this.$refs['form'].validate((valid) => {
if (valid) {
let base64List=[]
this.fileList.map(item=>this.changeBase64(item.raw,base64List))
setTimeout(()=>{
if(this.rtype=='update'){
/* 其他情况*/
let oldBase64List=this.form.photo||[]
let fin=[...oldBase64List,...base64List]
this.form.photo=fin
this.app.showDialog = false
}else{
/* 新增这时候*/
this.form.photo=base64List
this.$emit('save', this.form)
}
},1500)
}
})
......
......@@ -7,6 +7,33 @@
v-for="(item,index) in editColItemList " :value="item.value" :span="item.span" :label="item.label"
:prop='item.prop' :key="item.prop" :type="item.type" :typeConfig='item.typeConfig' :rule="item.rule" />
</el-row>
<el-row :gutter="20">
<el-form-item label="图片">
<el-upload :on-change='change' ref="upload" action='attachment/upload/tmp' :auto-upload='false' list-type="picture-card"
:on-remove="handleRemove" >
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-row>
<el-row >
<el-form-item label="已上传附件">
<div class="demo-image">
<div style="display: inline-block;" v-for="(item,index) in form.photo" :key="item.id">
<div>
<el-image :preview-src-list="form.photo.map(item=>item)"
style="width: 146.22px; height: 146.22px;margin-right: 10px;" :src="item" fit="fill">
</el-image>
<div v-show="type=='edit'" @click='delfile(index)'
style="width: 146.22px;line-height: 15px;font-size: 13px;color: red;text-align: center;cursor: pointer;">
删除</div>
</div>
</div>
</div>
</el-form-item>
</el-row>
</el-form>
<div slot="reFooter" class="refooter">
<span slot="footer" class="dialog-footer">
......@@ -20,7 +47,7 @@
import {
editMixin
} from 'common'
import wlxx from '@/views/auxinput/wlxx'
export default {
......@@ -38,6 +65,7 @@ import wlxx from '@/views/auxinput/wlxx'
},
data() {
return {
fileList:[],
readonly: false,
editColItemList: [
{
......@@ -70,10 +98,53 @@ import wlxx from '@/views/auxinput/wlxx'
}
},
methods: {
delfile(index){
this.form.splice(index,1)
},
changeBase64(file,base64List){
const reader = new FileReader();
// 读取文件内容,并在读取完成后调用 onload 事件处理函数
reader.onload = function(event) {
// event.target.result 包含了文件的 Base64 编码字符串
const base64String = event.target.result;
base64List.push(base64String)
// 你可以在这里使用 base64String,例如发送到服务器或显示在页面上
};
// 读取文件为 Data URL(Base64 编码)
return reader.readAsDataURL(file)
},
change(file, fileList){
this.fileList=fileList
},
handleRemove(file, fileList){
this.fileList=fileList
},
save() {
this.$refs['form'].validate((valid) => {
if (valid) {
let base64List=[]
this.fileList.map(item=>this.changeBase64(item.raw,base64List))
setTimeout(()=>{
if(this.rtype=='update'){
/* 其他情况*/
let oldBase64List=this.form.photo||[]
let fin=[...oldBase64List,...base64List]
this.form.photo=fin
this.app.showDialog = false
}else{
/* 新增这时候*/
this.form.photo=base64List
this.$emit('save', this.form)
}
},1500)
}
})
......
......@@ -38,6 +38,7 @@
},
data() {
return {
fileList:[],
readonly: false,
editColItemList: [{
label: '设备名称',
......
......@@ -3,10 +3,10 @@
:buttonApp='buttonApp'>
<el-form slot="form" ref="form" :model="form" label-width="120px" :rules="rules"
style="height: 70vh;overflow: auto;overflow-x: hidden;">
<addgjmx @save='addgjmxbc' v-if="showDialog&&DialogTitle=='新增工具'" :app="this"></addgjmx>
<addbpbjmx @save='savebpbj' v-if="showDialog&&DialogTitle=='新增备品备件'" :app="this"></addbpbjmx>
<addhcmx @save='savehc' v-if="showDialog&&DialogTitle=='新增耗材'" :app="this"></addhcmx>
<addjxzyff @save='savejxzyff' v-if="showDialog&&DialogTitle=='新增检修作业方法'" :app="this" />
<addgjmx ref="addgjmx" @save='addgjmxbc' v-if="showDialog&&DialogTitle=='工具'" :app="this"></addgjmx>
<addbpbjmx ref="addbpbjmx" @save='savebpbj' v-if="showDialog&&DialogTitle=='备品备件'" :app="this"></addbpbjmx>
<addhcmx ref="addhcmx" @save='savehc' v-if="showDialog&&DialogTitle=='耗材'" :app="this"></addhcmx>
<addjxzyff ref="addjxzyff" @save='savejxzyff' v-if="showDialog&&DialogTitle=='检修作业方法'" :app="this" />
<el-row :gutter="20" :app="this">
<EditColItem :required="item.required||false" :readonly="item.readonly?true:false "
v-for="(item,index) in editColItemList " :value="item.value" :span="item.span" :label="item.label"
......@@ -17,9 +17,10 @@
<el-tab-pane label="检修工具" name="1">
<div style="height: 300px;">
<editTableForEdit :phsxTitle='false' :expandTitle='false' code='false' :AuxButton='false' :indexApp='app'
:type='type' ref="editTableForEdit1" :editTableTitle='editTableTitle1' :editTableData="editTableData1">
:type='type' ref="jxgjTab" :editTableTitle='editTableTitle1' :editTableData="editTableData1">
<template v-if="type!='view'" #toolbar="ctx">
<el-button @click="addjxgj" size='mini' type="primary">新增检修工具</el-button>
<el-button @click="cktzjxgj" size='mini' type="primary">查看调整检修工具</el-button>
</template>
</editTableForEdit>
</div>
......@@ -27,9 +28,10 @@
<el-tab-pane v-if="form.sfsybpbj=='Y'" label="备品备件使用" name="2">
<div style="height: 300px;">
<editTableForEdit :phsxTitle='false' :expandTitle='false' code='false' :AuxButton='false' :indexApp='app'
:type='type' ref="editTableForEdit1" :editTableTitle='editTableTitle2' :editTableData="editTableData2">
:type='type' ref="bpbjTab" :editTableTitle='editTableTitle2' :editTableData="editTableData2">
<template v-if="type!='view'" #toolbar="ctx">
<el-button @click="addbpbj" size='mini' type="primary">新增备品备件</el-button>
<el-button @click="cktzbpbj" size='mini' type="primary">查看调整备品备件</el-button>
</template>
</editTableForEdit>
</div>
......@@ -37,9 +39,10 @@
<el-tab-pane v-if="form.sfsyhc=='Y'" label="耗材使用" name="3">
<div style="height: 300px;">
<editTableForEdit :phsxTitle='false' :expandTitle='false' code='false' :AuxButton='false' :indexApp='app'
:type='type' ref="editTableForEdit1" :editTableTitle='editTableTitle3' :editTableData="editTableData3">
:type='type' ref="hcTab" :editTableTitle='editTableTitle3' :editTableData="editTableData3">
<template v-if="type!='view'" #toolbar="ctx">
<el-button @click="addhcmx" size='mini' type="primary">新增耗材</el-button>
<el-button @click="cktzhc" size='mini' type="primary">查看调整耗材</el-button>
</template>
</editTableForEdit>
</div>
......@@ -47,10 +50,11 @@
<!-- 检修作业方法-->
<el-tab-pane label="检修作业方法" name="5">
<div style="height: 300px;">
<editTableForEdit :phsxTitle='false' :expandTitle='false' code='false' :AuxButton='false' :indexApp='app'
:type='type' ref="editTableForEdit1" :editTableTitle='editTableTitle4' :editTableData="editTableData4">
<editTableForEdit ref="jxzyffTab" :phsxTitle='false' :expandTitle='false' code='false' :AuxButton='false' :indexApp='app'
:type='type' :editTableTitle='editTableTitle4' :editTableData="editTableData4">
<template v-if="type!='view'" #toolbar="ctx">
<el-button @click="addjxzyff" size='mini' type="primary">新增检修作业</el-button>
</template>
</editTableForEdit>
</div>
......@@ -591,20 +595,102 @@
this.showDialog = false
},
addjxgj() {
this.DialogTitle = '新增工具'
this.DialogTitle = '工具'
this.showDialog = true
},
cktzjxgj() {
let singleItem = this.$refs.jxgjTab.$refs.editTable.singleItem
if(Object.keys(singleItem).length==0){
this.$warning('请选中一条数据进行操作')
}else{
this.DialogTitle = '工具'
this.showDialog = true
this.$nextTick(()=>{
if(Array.isArray(singleItem.photo)){
}else{
singleItem.photo=JSON.parse(singleItem.photo)
}
console.log(this.$refs.addgjmx)
this.$refs.addgjmx.form=singleItem
this.$refs.addgjmx.rtype='update'
})
}
},
addbpbj() {
this.DialogTitle = '新增备品备件'
this.DialogTitle = '备品备件'
this.showDialog = true
},
cktzbpbj() {
let singleItem = this.$refs.bpbjTab.$refs.editTable.singleItem
if(Object.keys(singleItem).length==0){
this.$warning('请选中一条数据进行操作')
}else{
this.DialogTitle = '备品备件'
this.showDialog = true
this.$nextTick(()=>{
if(Array.isArray(singleItem.photo)){
}else{
singleItem.photo=JSON.parse(singleItem.photo)
}
this.$refs.addbpbjmx.form=singleItem
this.$refs.addbpbjmx.rtype='update'
})
}
},
addhcmx() {
this.DialogTitle = '新增耗材'
this.DialogTitle = '耗材'
this.showDialog = true
},
cktzhc(){
let singleItem = this.$refs.hcTab.$refs.editTable.singleItem
if(Object.keys(singleItem).length==0){
this.$warning('请选中一条数据进行操作')
}else{
this.DialogTitle = '耗材'
this.showDialog = true
this.$nextTick(()=>{
if(Array.isArray(singleItem.photo)){
}else{
singleItem.photo=JSON.parse(singleItem.photo)
}
this.$refs.addhcmx.form=singleItem
this.$refs.addhcmx.rtype='update'
})
}
},
addjxzyff(){
this.DialogTitle = '新增检修作业方法'
this.DialogTitle = '检修作业方法'
this.showDialog = true
},
cktzjxzyff(){
let singleItem = this.$refs.jxzyffTab.$refs.editTable.singleItem
if(Object.keys(singleItem).length==0){
this.$warning('请选中一条数据进行操作')
}else{
this.DialogTitle = '检修作业方法'
this.showDialog = true
this.$nextTick(()=>{
if(Array.isArray(singleItem.photo)){
}else{
singleItem.photo=JSON.parse(singleItem.photo)
}
console.log(singleItem)
this.$refs.addjxzyff.form=singleItem
this.$refs.addjxzyff.rtype='update'
})
}
}
}
}
......
<template>
<RelDialog width="50%" :type='type' :editApp='editApp' :app='app' :buttonApp='buttonApp'>
<RelDialog :attachments='attachments' width="50%" :type='type' :editApp='editApp' :app='app' @getForm='getForm' :buttonApp='buttonApp'>
<el-form slot="form" ref="form" :model="form" label-width="100px" :rules="rules">
<el-row :gutter="20" :app="this">
<EditColItem :required="item.required||false" :readonly="item.readonly?true:false "
v-for="(item,index) in editColItemList " :value="item.value" :span="item.span" :label="item.label"
:prop='item.prop' :key="item.prop" :type="item.type" :typeConfig='item.typeConfig' :rule="item.rule" />
</el-row>
<!-- 附件数据-->
<el-row v-if="type!='view'" :gutter="20">
<el-form-item label="异物图片">
<el-upload ref="upload" :headers='{
Gtoken
}' :action="`${baseurl}/attachment/upload/tmp`" list-type="picture-card"
:on-preview="handlePictureCardPreview" :on-success='success' :on-remove="handleRemove" :data="{
groupid:'',
folder:'uywsjlr'
}">
<i class="el-icon-plus"></i>
</el-upload>
</el-form-item>
</el-row>
<el-row v-if="showList.length!=0">
<el-form-item label="已上传附件">
<div class="demo-image">
<div style="display: inline-block;" v-for="(item,index) in showList" :key="item.id">
<div>
<el-image :preview-src-list="showList.map(item=>item.url)"
style="width: 146.22px; height: 146.22px;margin-right: 10px;" :src="item.url" fit="fill">
</el-image>
<div v-show="type=='edit'" @click='delfile(item.id,index)'
style="width: 146.22px;line-height: 15px;font-size: 13px;color: red;text-align: center;cursor: pointer;">
删除</div>
</div>
</div>
</div>
</el-form-item>
</el-row>
<!-- 分割-->
</el-form>
</RelDialog>
</template>
<script>
const baseurl = process.env.VUE_APP_BASE_API
const Gtoken = localStorage.getItem('Gtoken')
import {
autoAttachDownload
} from "common/src/api/system/dmgSystem.js";
import {
editMixin
} from 'common'
import sbxx from '@/views/auxinput/sbxx'
export default {
mixins: [editMixin],
computed:{
attachments(){
let attachments=[]
this.attachmentList.forEach(item=>{
attachments.push({
id:item
})
})
this.showList.forEach(item=>{
attachments.push({
id:item.id
})
})
return attachments
}
},
data() {
return {
/* 附件*/
attachmentList:[],
showList:[],
baseurl: baseurl,
Gtoken: Gtoken,
/* 附件*/
editColItemList: [{
label: '设备名称',
prop: 'sbxxCode',
......@@ -121,6 +184,78 @@
]
}
},
methods:{
handleRemove(file, fileList) {
let attachmentList = []
fileList.forEach(item => {
if (item.status == 'success') {
attachmentList.push(item.response.data.records.id)
}
})
this.attachmentList = attachmentList
console.log(this.attachmentList)
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
this.dialogVisible = true;
},
success(res, file, fileList) {
if (res.success) {
this.$success('上传成功')
/* 成功后同步fileList数据到form表单*/
let attachmentList = []
fileList.forEach(item => {
if (item.status == 'success') {
attachmentList.push(item.response.data.records.id)
}
})
this.attachmentList = attachmentList
} else {
const delIndex = fileList.findIndex(item => item.uid === file.uid);
if (delIndex !== -1) {
fileList.splice(delIndex, 1);
this.$error(res.message || '未知错误');
}
}
},
delfile(id, index) {
this.$confirm('是否继续该操作?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(res => {
this.showList.splice(index, 1)
})
},
getForm(data) {
this.$post('ywxxgl/uywxx/attachment/list', {
groupid: data.id,
}).then(res => {
res.data.records.forEach(item => {
autoAttachDownload({}, 'ywxxgl/uywxx', item.id).then(res => {
let blob = new Blob([res], {
type: 'application/' + item.type + ';charset=UTF-8',
});
let url = URL.createObjectURL(blob)
let uitem = {
url,
id: item.id
}
this.showList.push(uitem)
})
})
})
},
}
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment