Commit cecf4337 authored by 李苏's avatar 李苏 💬

调整

parent 3fc633a0
......@@ -3,12 +3,23 @@
* @Author: lisu lisu@gavelinfo.com
* @Date: 2024-09-19 10:47:46
* @LastEditors: lisu lisu@gavelinfo.com
* @LastEditTime: 2024-10-29 10:16:41
* @LastEditTime: 2025-01-09 14:44:50
* @FilePath: /zghywpc-vue/src/views/ywxxgl/jdlcdxgsjs/edit.vue
-->
<template>
<!-- prop 穿透赋值 -->
<BaseEdit v-bind="$attrs" :config='editConfig'>
<BaseEdit ref='baseEdit' @getForm='getForm' :attachments='attachments' v-bind="$attrs" :config='editConfig'>
<template #form="ctx">
<!-- 嵌入默认页面额外弹框的插槽 ctx.editPage来操作默认页面 -->
<el-form-item label="上传附件">
<UploadTmp @getUploadFile='getUploadFile' @getList='uploadGetList' />
</el-form-item>
<el-form-item label="附件列表">
<AttachmentList :canDelete='ctx.baseEdit.type=="view"?false:true' url='ywxxgl/ujdlcdxgsjs/attachment'
:params='attachmentListParams' ref="attachmentList" @getList='attachmentListGetList' />
</el-form-item>
</template>
<template #dialog="ctx">
<!-- 嵌入默认页面额外弹框的插槽 ctx.editPage来操作默认页面 -->
</template>
......@@ -24,9 +35,21 @@
</template>
<script>
import * as XLSX from 'xlsx';
export default {
computed: {
attachments() {
return [...this.uploadAttachments, ...this.attachmentListAttachments]
}
},
data() {
return {
uploadAttachments: [],
attachmentListAttachments: [],
attachmentListParams: {
groupid: ''
},
editConfig: {
/* 生成form表单 */
editColItemList: [{
......@@ -34,7 +57,7 @@
"prop": "year",
"span": 12,
"type": "year", // 对于整型字段,一般使用input类型
value:new Date().getFullYear(),
value: new Date().getFullYear(),
"required": true,
},
{
......@@ -45,8 +68,7 @@
"value": "",
"required": true,
"typeConfig": {
optionsData:[
{
optionsData: [{
id: 1,
name: '第一季度'
},
......@@ -68,7 +90,7 @@
"label": "name"
}
},
value:this.getQuarterFromTimestamp(new Date().getTime())
value: this.getQuarterFromTimestamp(new Date().getTime())
},
{
"label": "大修",
......@@ -106,10 +128,17 @@
"value": "" // 默认值,如果需要可以移除或修改
},
{
"label": "人员",
"prop": "ryName",
"span": 12,
"type": "input", // 未标明特殊类型或ftString类型默认为input
"value": "" // 默认值,如果需要可以移除或修改
},
{
"label": "合计",
"prop": "hj",
"span": 24,
"span": 12,
"type": "input", // 未标明特殊类型或ftString类型默认为input
"value": "" // 默认值,如果需要可以移除或修改
},
......@@ -150,7 +179,57 @@
}
}
},
methods: {
readExcelFile(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = (e) => {
const data = new Uint8Array(e.target.result);
const workbook = XLSX.read(data, {
type: 'array'
});
const worksheet = workbook.Sheets[workbook.SheetNames[0]];
const jsonData = XLSX.utils.sheet_to_json(worksheet, {
header: 1
});
resolve(jsonData);
};
reader.onerror = (e) => {
reject(e);
};
reader.readAsArrayBuffer(file);
})
},
getUploadFile(file) {
const name = file.name
/* 根据文件名判定是否是excel文件*/
if (name.includes('xlsx')) {
this.readExcelFile(file.raw).then(data => {
console.log(data[16],data)
this.$refs.baseEdit.form.ryName = data[16][1]
this.$refs.baseEdit.form.hj = data[17][1]
})
}
},
getForm(e) {
this.attachmentListParams.groupid = e.id
this.$nextTick(() => {
this.$refs.attachmentList.init()
})
},
uploadGetList(e) {
this.uploadAttachments = e
},
attachmentListGetList(e) {
this.attachmentListAttachments = e
},
getQuarterFromTimestamp(timestamp) {
const date = new Date(timestamp);
const month = date.getMonth(); // 月份从0开始,0表示1月,11表示12月
......
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