From f6379a640d6c580582ecf01b6293a5ed334f428d Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 14 九月 2023 17:37:12 +0800
Subject: [PATCH] 1.导入数据 正在修改bug
---
src/views/systemSetting/dataImport.vue | 485 +++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 357 insertions(+), 128 deletions(-)
diff --git a/src/views/systemSetting/dataImport.vue b/src/views/systemSetting/dataImport.vue
index 6462bdf..b3f4709 100644
--- a/src/views/systemSetting/dataImport.vue
+++ b/src/views/systemSetting/dataImport.vue
@@ -1,7 +1,7 @@
<template>
<div class="" :style="{height:mainHeight+'px'}">
- <div style="display: flex;margin: 20px 10px;">
+ <div style="display: flex;margin: 20px 10px;align-items: center">
<el-select
v-model="excelCode"
@@ -22,6 +22,7 @@
type="primary"
style="margin-left: 20px"
:disabled="excelCode===''"
+ icon="el-icon-download"
@click="getExcel"
>涓嬭浇妯℃澘
</el-button>
@@ -36,17 +37,36 @@
type="info"
style="margin-left: 20px"
:disabled="excelCode===''"
+ icon="el-icon-refresh"
@click="reset"
>閲嶇疆
</el-button>
<el-button
- type="primary"
+ type="warning"
style="margin-left: 20px"
- :disabled="excelCode===''"
- @click="submit"
- >鎻愪氦
+ icon="el-icon-circle-plus-outline"
+ :disabled="excelCode===''||tableData.length===0"
+ @click="addRow"
+ >鏂板琛�
</el-button>
+
+ <el-button
+ type="success"
+ style="margin-left: 20px"
+ :disabled="excelCode===''||tableData.length===0"
+ icon="el-icon-thumb"
+ @click="submit"
+ >鎻愪氦鏁版嵁
+ </el-button>
+
+ <!-- <el-button-->
+ <!-- type="danger"-->
+ <!-- style="margin-left: 20px"-->
+ <!-- :disabled="excelCode===''||tableData.length===0"-->
+ <!-- @click="batchDel"-->
+ <!-- >鎵归噺鍒犻櫎-->
+ <!-- </el-button>-->
</div>
@@ -61,9 +81,10 @@
:key="i+j"
:label="i"
>
- <!-- height:(mainHeight-180)+'px',-->
+ <!-- :key="tableKey"-->
<el-table
- ref="tableDataRef"
+ v-if="tableData[j].length>0"
+ :ref="'tableDataRef'+i"
:data="tableData[j]"
border
:height="(mainHeight-180)+'px'"
@@ -73,17 +94,18 @@
style="overflow-y: scroll;"
highlight-current-row
>
- <!-- <el-table-column-->
- <!-- type="selection"-->
- <!-- width="55"-->
- <!-- />-->
+
<el-table-column
- type="index"
label="搴忓彿"
width="55"
fixed
align="center"
- />
+ :render-header="indexRender"
+ >
+ <template slot-scope="scope">
+ {{ scope.$index + 1 }}
+ </template>
+ </el-table-column>
<el-table-column
v-for="item of tableHeader[j]"
@@ -92,21 +114,42 @@
:label="item"
align="center"
:render-header="addRedStar"
- width="220"
+ min-width="220"
>
<template slot-scope="{row}">
<div
- v-if="item.indexOf('鐢ㄦ埛缂栧彿(鍞竴)')!==-1||
- item.indexOf('鐢ㄦ埛濮撳悕')!==-1||
+ v-if="item.indexOf('缂栧彿(鍞竴)')!==-1||
item.indexOf('瀵嗙爜')!==-1||
item.indexOf('鎵嬫満鍙�')!==-1||
- item.indexOf('閭')!==-1
+ item.indexOf('閭')!==-1||
+ item.indexOf('鍚嶇О')!==-1||
+ item.indexOf('鎻忚堪')!==-1
"
>
<el-input v-model="row[item]" placeholder="璇疯緭鍏�" />
</div>
- <div v-else-if="item.indexOf('鍦ㄨ亴鐘舵��')!==-1">
+ <div
+ v-else-if="item.indexOf('鐢ㄦ埛濮撳悕')!==-1"
+ >
+ <el-input v-model="row[item]" placeholder="璇疯緭鍏�" />
+ </div>
+ <div v-else-if="item.indexOf('鏁版嵁鑼冨洿')!==-1">
+ <el-select
+ v-model="row[item]"
+ placeholder="璇烽�夋嫨"
+ filterable
+ clearable
+ >
+ <el-option
+ v-for="item in powerArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </div>
+ <div v-else-if="item.indexOf('鐘舵��')!==-1">
<el-select
v-model="row[item]"
placeholder="璇烽�夋嫨"
@@ -121,7 +164,6 @@
/>
</el-select>
</div>
-
<div v-else-if="item.indexOf('鎵�灞炲矖浣嶇紪鐮�')!==-1">
<el-select
v-model="row[item]"
@@ -178,40 +220,61 @@
</el-select>
</div>
<div v-else-if="item.indexOf('鎵�灞炵粍缁囩紪鐮�')!==-1">
- <el-select
+ <el-cascader
+ ref="cascader"
v-model="row[item]"
- style="width: 100%;"
- placeholder="璇烽�夋嫨"
+ :options="orgOptions"
filterable
- clearable
- >
- <el-option
- v-for="item in orgArr"
- :key="item.torg_code"
- :label="item.torg_name"
- :value="item.torg_code"
- />
- </el-select>
+ :props="defaultProps"
+ :show-all-levels="false"
+ />
+ </div>
+ <div v-else-if="item.indexOf('鏁版嵁鏉冮檺')!==-1">
+ <el-cascader
+ ref="cascader"
+ v-model="row[item]"
+ :options="orgOptions"
+ filterable
+ collapse-tags
+ :disabled="row['鏁版嵁鑼冨洿']!=='CUSTOM'"
+ :props="orgDefaultProps"
+ :show-all-levels="false"
+ />
</div>
<div v-else> {{ row[item] }}</div>
</template>
</el-table-column>
+
<el-table-column
label="鎿嶄綔"
- width="120"
+ width="55"
+ :render-header="operationRender"
fixed="right"
- />
+ >
+ <template slot-scope="{row}">
+ <div class="operationClass" style="padding-left: 10px">
+ <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+ <i
+ class="el-icon-delete"
+ :style="{color:$store.state.settings.theme}"
+ @click="delRow(row)"
+ />
+ </el-tooltip>
+ </div>
+ </template>
+ </el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</div>
- <!-- <div v-for="(i,j) in tableHeader" :key="i">-->
- <!-- <el-table :data="tableData[j]" border highlight-current-row style="width: 100%;margin-top:20px;">-->
- <!-- <el-table-column v-for="item of tableHeader[j]" :key="item" :prop="item" :label="item" />-->
- <!-- </el-table>-->
- <!-- </div>-->
+ <el-empty v-if="tableData.length===0" :image-size="500">
+ <el-button type="text">1.璇烽�夋嫨妯℃澘涓嬭浇</el-button>
+ <el-button type="text" style="margin-left: 0;">2.璇峰~鍐欐ā鏉挎暟鎹�</el-button>
+ <el-button type="text" style="margin-left: 0;">3.璇蜂笂浼犳枃浠舵彁浜�</el-button>
+ </el-empty>
+
</div>
</template>
@@ -219,6 +282,8 @@
import UploadExcelComponent from '@/components/UploadExcel/index.vue'
import { DownLoadExcel, ExcelModelCheck, ExcelModelData } from '@/api/Excel'
import { GroupsPermissions, PostPermissions, PrentOrganization, RolePermissions } from '@/api/GeneralBasicData'
+import { nanoid } from 'nanoid'
+import arrayToTree from 'array-to-tree'
export default {
name: 'UploadExcel',
@@ -234,14 +299,33 @@
excelCode: '',
excelArr: [],
- statusArr: [
- { code: 'Y', name: '鍦ㄨ亴' },
- { code: 'N', name: '绂昏亴' }
- ],
+ statusArr: [],
orgArr: [], // 缁勭粐
+ orgOptions: [],
+ defaultProps: {
+ checkStrictly: true,
+ expandTrigger: 'hover',
+ value: 'torg_code',
+ label: 'torg_name'
+ },
+ orgDefaultProps: {
+ multiple: true,
+ expandTrigger: 'hover',
+ value: 'torg_code',
+ label: 'torg_name'
+ },
postArr: [], // 宀椾綅
roleArr: [], // 瑙掕壊
- groupArr: []// 鐝粍
+ groupArr: [], // 鐝粍
+
+ powerArr: [
+ { code: 'ALL', name: '鍏ㄩ儴' },
+ { code: 'LEVEL', name: '鏈骇' },
+ { code: 'PERSON', name: '鏈汉' },
+ { code: 'CUSTOM', name: '鑷畾涔�' }
+ ], // 鏁版嵁鑼冨洿
+
+ tableKey: new Date().getTime()
}
},
@@ -274,102 +358,244 @@
return false
},
async handleSuccess({ results, header, sheetName }) {
+ if (results[0].length === 0) {
+ return this.$message.info('琛ㄦ牸鏁版嵁涓嶈兘涓虹┖锛�')
+ }
this.tableData = results
this.tableHeader = header
this.sheetName = sheetName
- // 鐢ㄦ埛娓呭崟瀵煎叆鍒ゆ柇
- if (this.sheetName.indexOf('鐢ㄦ埛娓呭崟') !== -1) {
+ console.log(this.tableData)
+ console.log(this.tableHeader)
+
+ // this.tableHeader
+
+ // 浜哄憳绠$悊瀵煎叆鍒ゆ柇
+ if (this.sheetName.indexOf('浜哄憳绠$悊') !== -1) {
+ this.statusArr = [
+ { code: 'Y', name: '鍦ㄨ亴' },
+ { code: 'N', name: '绂昏亴' }
+ ]
const postArr = this.postArr.map(i => i.postcode)
const roleArr = this.roleArr.map(i => i.rolecode)
const groupArr = this.groupArr.map(i => i.usergroupcode)
const orgArr = this.orgArr.map(i => i.torg_code)
- this.tableData[this.sheetName.indexOf('鐢ㄦ埛娓呭崟')].forEach(j => {
- j.鎵�灞炲矖浣嶇紪鐮� = j.鎵�灞炲矖浣嶇紪鐮�.split(',').filter(e => postArr.includes(e))
- j.鎵�灞炶鑹茬紪鐮� = j.鎵�灞炶鑹茬紪鐮�.split(',').filter(e => roleArr.includes(e))
- j.鎵�灞炵彮缁勭紪鐮� = j.鎵�灞炵彮缁勭紪鐮�.split(',').filter(e => groupArr.includes(e))
- j['*鎵�灞炵粍缁囩紪鐮�'] = orgArr.includes(j['*鎵�灞炵粍缁囩紪鐮�']) ? j['*鎵�灞炵粍缁囩紪鐮�'] : ''
- j['*鍦ㄨ亴鐘舵��'] = this.statusArr.find(e => e.name === j['*鍦ㄨ亴鐘舵��']).code
+
+ // this.sheetName.indexOf('浜哄憳绠$悊')
+ this.tableData[0].forEach(j => {
+ // j.鎵�灞炲矖浣嶇紪鐮� = typeof j.鎵�灞炲矖浣嶇紪鐮� === 'undefined' ? new Set() : j.鎵�灞炲矖浣嶇紪鐮�.split(',').filter(e => postArr.includes(e))
+ // j.鎵�灞炶鑹茬紪鐮� = typeof j.鎵�灞炶鑹茬紪鐮� === 'undefined' ? ''.split(',') : j.鎵�灞炶鑹茬紪鐮�.split(',').filter(e => roleArr.includes(e))
+ // j.鎵�灞炵彮缁勭紪鐮� = typeof j.鎵�灞炵彮缁勭紪鐮� === 'undefined' ? ''.split(',') : j.鎵�灞炵彮缁勭紪鐮�.split(',').filter(e => groupArr.includes(e))
+
+ j['鎵�灞炲矖浣嶇紪鐮�'] = j['鎵�灞炲矖浣嶇紪鐮�'] ? j['鎵�灞炲矖浣嶇紪鐮�'].split(',').filter(e => postArr.includes(e)) : []
+ j['鎵�灞炶鑹茬紪鐮�'] = j['鎵�灞炶鑹茬紪鐮�'] ? j['鎵�灞炶鑹茬紪鐮�'].split(',').filter(e => roleArr.includes(e)) : []
+ j['鎵�灞炵彮缁勭紪鐮�'] = j['鎵�灞炵彮缁勭紪鐮�'] ? j['鎵�灞炵彮缁勭紪鐮�'].split(',').filter(e => groupArr.includes(e)) : []
+ j['*鎵�灞炵粍缁囩紪鐮�'] = j['*鎵�灞炵粍缁囩紪鐮�'] ? (orgArr.includes(j['*鎵�灞炵粍缁囩紪鐮�']) ? j['*鎵�灞炵粍缁囩紪鐮�'] : '') : ''
+ j['*鍦ㄨ亴鐘舵��'] = j['*鍦ㄨ亴鐘舵��'] ? this.statusArr.find(e => e.name === j['*鍦ㄨ亴鐘舵��']).code : 'Y'
+
+ // j['鎵嬫満鍙�'] = j['鎵嬫満鍙�'] ? j['鎵嬫満鍙�'] : ''
+ // j['閭'] = j['閭'] ? j['閭'] : ''
+ // j['*瀵嗙爜'] = j['*瀵嗙爜'] ? j['*瀵嗙爜'] : ''
+ // j['*鐢ㄦ埛濮撳悕'] = j['*鐢ㄦ埛濮撳悕'] ? j['*鐢ㄦ埛濮撳悕'] : ''
+ // j['*鐢ㄦ埛缂栧彿(鍞竴)'] = j['*鐢ㄦ埛缂栧彿(鍞竴)'] ? j['*鐢ㄦ埛缂栧彿(鍞竴)'] : ''
+ j.uuid = nanoid()
+ })
+
+ // this.tableKey = 'asd'
+ // this.$forceUpdate()
+ }
+
+ if (this.sheetName.indexOf('瑙掕壊绠$悊') !== -1) {
+ this.statusArr = [
+ { code: 'Y', name: '鍋滅敤' },
+ { code: 'N', name: '鍚敤' }
+ ]
+
+ this.tableData[0].forEach(j => {
+ // j.鎵�灞炲矖浣嶇紪鐮� = j.鎵�灞炲矖浣嶇紪鐮�.split(',').filter(e => postArr.includes(e))
+ // console.log(j['鏁版嵁鏉冮檺'], 1) // 绾ц仈澶氶�夊洖鏄� 寰呯爺绌� 涓嬫鍐�
+ j['鏁版嵁鑼冨洿'] = this.powerArr.find(e => e.name === j['鏁版嵁鑼冨洿']).code
+ j['*鐘舵��'] = this.statusArr.find(e => e.name === j['*鐘舵��']).code
+ j.uuid = nanoid()
})
}
},
+
+ // 鑾峰彇妯℃澘
async getExcelModelData() {
const { data: res } = await ExcelModelData()
this.excelArr = res
+
+ if (window.location.hash.indexOf('?') !== -1) {
+ this.excelCode = window.location.hash.split('?')[1].split('=')[1]
+ }
},
+ // 妯℃澘涓嬭浇
async getExcel() {
const res = await DownLoadExcel({ FileCode: this.excelCode })
window.location.href = res.data
},
submit() {
- // console.log(this.excelCode)
- // console.log(JSON.stringify(this.sheetName))
- // console.log(JSON.stringify(this.tableHeader))
- // console.log(JSON.stringify(this.tableData))
-
this.$confirm('鏄惁纭鎻愪氦?', '鎻愮ず', {
confirmButtonText: '纭畾',
cancelButtonText: '鍙栨秷',
type: 'warning'
- }).then(() => {
- let flag = true
- let msg = ''
- if (this.sheetName.indexOf('鐢ㄦ埛娓呭崟') !== -1) {
- // if ([...new Set(this.tableData[0].filter(i => i['*鐢ㄦ埛缂栧彿(鍞竴)'] !== '').map(i => i['*鐢ㄦ埛缂栧彿(鍞竴)']))].length !== this.tableData[0].length) {
- if ([...new Set(this.tableData[0].map(i => i['*鐢ㄦ埛缂栧彿(鍞竴)']))].length !== this.tableData[0].length) {
- return this.$message.info('缂栫爜涓嶈兘閲嶅锛�')
- }
- this.tableData[0].forEach(j => {
- if (j['*鐢ㄦ埛缂栧彿(鍞竴)'].trim() === '') {
- flag = false
- msg = '*鐢ㄦ埛缂栧彿(鍞竴)'
- }
- if (j['*鐢ㄦ埛濮撳悕'].trim() === '') {
- flag = false
- msg = '*鐢ㄦ埛濮撳悕'
- }
- if (j['*瀵嗙爜'].trim() === '') {
- flag = false
- msg = '*瀵嗙爜'
- }
- if (j['*鍦ㄨ亴鐘舵��'].trim() === '') {
- flag = false
- msg = '*鍦ㄨ亴鐘舵��'
- }
- if (j['*鎵�灞炵粍缁囩紪鐮�'].trim() === '') {
- flag = false
- msg = '*鎵�灞炵粍缁囩紪鐮�'
- }
- })
-
- if (!flag) {
- return this.$message.info(msg + '涓嶈兘涓虹┖锛�')
- }
-
- this.tableData[0].forEach(j => {
- j.鎵�灞炲矖浣嶇紪鐮� = j.鎵�灞炲矖浣嶇紪鐮�.join(',')
- j.鎵�灞炵彮缁勭紪鐮� = j.鎵�灞炵彮缁勭紪鐮�.join(',')
- j.鎵�灞炶鑹茬紪鐮� = j.鎵�灞炶鑹茬紪鐮�.join(',')
- })
- }
- const data = {
- fileCode: this.excelCode,
- tableData: this.tableData
- }
- // console.log(JSON.stringify(this.tableData))
- ExcelModelCheck(data).then(res => {
- if (res.code === '200') {
- this.$notify.success('鎻愪氦鎴愬姛!')
- this.tableData = []
- this.tableHeader = []
- this.sheetName = []
- this.excelCode = ''
- }
- })
- }).catch(() => {
- this.$notify.info('宸插彇娑堟彁浜わ紒')
})
+ .then(() => {
+ let flag = true
+ let msg = ''
+ if (this.sheetName.indexOf('浜哄憳绠$悊') !== -1) {
+ if ([...new Set(this.tableData[0].map(i => i['*鐢ㄦ埛缂栧彿(鍞竴)']))].length !== this.tableData[0].length) {
+ return this.$message.info('缂栫爜涓嶈兘閲嶅锛�')
+ }
+ this.tableData[0].forEach(j => {
+ if (!j['*鐢ㄦ埛缂栧彿(鍞竴)']) {
+ flag = false
+ msg = '*鐢ㄦ埛缂栧彿(鍞竴)'
+ }
+
+ if (!j['*鐢ㄦ埛濮撳悕']) {
+ flag = false
+ msg = '*鐢ㄦ埛濮撳悕'
+ }
+ if (!j['*瀵嗙爜']) {
+ flag = false
+ msg = '*瀵嗙爜'
+ }
+ if (!j['*鍦ㄨ亴鐘舵��']) {
+ flag = false
+ msg = '*鍦ㄨ亴鐘舵��'
+ }
+ if (!j['*鎵�灞炵粍缁囩紪鐮�']) {
+ flag = false
+ msg = '*鎵�灞炵粍缁囩紪鐮�'
+ }
+ })
+
+ if (!flag) {
+ return this.$message.info(msg + '涓嶈兘涓虹┖锛�')
+ }
+
+ this.tableData[0].forEach(j => {
+ // j['鎵�灞炲矖浣嶇紪鐮�'] = typeof j['鎵�灞炲矖浣嶇紪鐮�'] === 'string' ? j['鎵�灞炲矖浣嶇紪鐮�'] : j['鎵�灞炲矖浣嶇紪鐮�'].join(',')
+ // j['鎵�灞炵彮缁勭紪鐮�'] = typeof j['鎵�灞炵彮缁勭紪鐮�'] === 'string' ? j['鎵�灞炵彮缁勭紪鐮�'] : j['鎵�灞炵彮缁勭紪鐮�'].join(',')
+ // j['鎵�灞炶鑹茬紪鐮�'] = typeof j['鎵�灞炶鑹茬紪鐮�'] === 'string' ? j['鎵�灞炶鑹茬紪鐮�'] : j['鎵�灞炶鑹茬紪鐮�'].join(',')
+ j['鎵�灞炲矖浣嶇紪鐮�'] = j['鎵�灞炲矖浣嶇紪鐮�'].join(',')
+ j['鎵�灞炵彮缁勭紪鐮�'] = j['鎵�灞炵彮缁勭紪鐮�'].join(',')
+ j['鎵�灞炶鑹茬紪鐮�'] = j['鎵�灞炶鑹茬紪鐮�'].join(',')
+ j['*鎵�灞炵粍缁囩紪鐮�'] = j['*鎵�灞炵粍缁囩紪鐮�'][j['*鎵�灞炵粍缁囩紪鐮�'].length - 1]
+ })
+
+ this.tableData[0].map(item => {
+ delete (item.uuid)
+ })
+ }
+
+ const data = {
+ fileCode: this.excelCode,
+ tableData: this.tableData
+ }
+
+ ExcelModelCheck(data).then(res => {
+ // 杩斿洖鐨刯son1銆乯son2銆乯son3 json1涓烘ā鏉挎牎楠屻�乯son2涓烘暟鎹牎楠屻�乯son3涓哄鍏ユ暟鎹簱鏍¢獙(鍙兘浼氭湁绯荤粺鎶ラ敊浜х敓)
+ if (res.json1.code !== '200' && res.json2 === null && res.json3 === null) {
+ this.$message.error(res.json1.message)
+ }
+ if (res.json1.code === '200' && res.json2 !== '200' && res.json3 === null) {
+ this.$message.error(res.json2.message)
+ }
+ if (res.json1.code === '200' && res.json2 === '200' && res.json3 !== '200') {
+ this.$message.error(res.json3.message)
+ }
+
+ // if (res.json1.code !== '200' && res.json2.code !== '200') {
+ // if (res.json2.code !== '200') {
+ if (this.sheetName.indexOf('浜哄憳绠$悊') !== -1) {
+ const postArr = this.postArr.map(i => i.postcode)
+ const roleArr = this.roleArr.map(i => i.rolecode)
+ const groupArr = this.groupArr.map(i => i.usergroupcode)
+ const orgArr = this.orgArr.map(i => i.torg_code)
+
+ this.tableData[0].forEach(j => {
+ j.鎵�灞炲矖浣嶇紪鐮� = j.鎵�灞炲矖浣嶇紪鐮�.split(',').filter(e => postArr.includes(e))
+ j.鎵�灞炶鑹茬紪鐮� = j.鎵�灞炶鑹茬紪鐮�.split(',').filter(e => roleArr.includes(e))
+ j.鎵�灞炵彮缁勭紪鐮� = j.鎵�灞炵彮缁勭紪鐮�.split(',').filter(e => groupArr.includes(e))
+ // j['*鍦ㄨ亴鐘舵��'] = this.statusArr.find(e => e.name === j['*鍦ㄨ亴鐘舵��']).code
+ // j['*鎵�灞炵粍缁囩紪鐮�'] = j['*鎵�灞炵粍缁囩紪鐮�'][j['*鎵�灞炵粍缁囩紪鐮�'].length - 1]
+ j['*鎵�灞炵粍缁囩紪鐮�'] = this.findParent([], j['*鎵�灞炵粍缁囩紪鐮�'], this.orgOptions).reverse()
+
+ j.uuid = nanoid()
+ })
+ }
+ // return this.$message.error(res.json1.message + ',' + res.json2.message)
+ // }
+
+ if (res.json1.code === '200' && res.json2 === '200' && res.json3 === '200') {
+ this.$notify.success('鏁版嵁鎻愪氦鎴愬姛!')
+ this.tableData = []
+ this.tableHeader = []
+ this.sheetName = []
+ this.excelCode = ''
+ } else {
+ this.$notify.error('鏁版嵁鎻愪氦澶辫触!')
+ }
+ })
+ })
+ .catch(e => {
+ console.log(e)
+ this.$notify.info('宸插彇娑堟彁浜わ紒')
+ })
},
+ // parents:鐢ㄤ簬杩斿洖鐨勬暟缁勶紝childNode:瑕佹煡璇㈢殑鑺傜偣锛宼reeData锛歫son鏍戝舰鏁版嵁
+ findParent(parents, childNode, treeData) {
+ // console.log(parents, childNode, treeData, 2)
+
+ for (let i = 0; i < treeData.length; i++) {
+ // 鐖惰妭鐐规煡璇㈡潯浠�
+ if (treeData[i].torg_code === childNode) {
+ // 濡傛灉鎵惧埌缁撴灉,淇濆瓨褰撳墠鑺傜偣
+ parents.push(treeData[i].torg_code)
+ // 鐢ㄥ綋鍓嶈妭鐐瑰啀鍘诲師鏁版嵁鏌ユ壘褰撳墠鑺傜偣鐨勭埗鑺傜偣
+ this.findParent(parents, treeData[i].parent_id, this.orgOptions)
+ break
+ } else {
+ if (treeData[i].children instanceof Array) {
+ // 娌℃壘鍒帮紝閬嶅巻璇ヨ妭鐐圭殑瀛愯妭鐐�
+ this.findParent(parents, childNode, treeData[i].children)
+ }
+ }
+ }
+ return parents
+ },
+ addRow() {
+ // 浜哄憳绠$悊鏂板琛�
+ if (this.sheetName.indexOf('浜哄憳绠$悊') !== -1) {
+ this.tableData[0].unshift({
+ uuid: nanoid(),
+ '*鐢ㄦ埛缂栧彿(鍞竴)': '',
+ '*鐢ㄦ埛濮撳悕': '',
+ '*瀵嗙爜': '',
+ '*鍦ㄨ亴鐘舵��': 'Y',
+ '鎵嬫満鍙�': '',
+ '閭': '',
+ '*鎵�灞炵粍缁囩紪鐮�': '',
+ '鎵�灞炲矖浣嶇紪鐮�': [],
+ '鎵�灞炶鑹茬紪鐮�': [],
+ '鎵�灞炵彮缁勭紪鐮�': []
+ })
+ }
+ },
+ delRow(row) {
+ // 浜哄憳绠$悊鍒犻櫎琛�
+ if (this.sheetName.indexOf('浜哄憳绠$悊') !== -1) {
+ if (this.tableData[0].length > 1) {
+ return this.tableData[0].splice(this.tableData[0].findIndex(i => i.uuid === row.uuid), 1)
+ } else {
+ return this.$message.info('蹇呴』瑕佹湁涓�鏉℃暟鎹紒')
+ }
+ }
+ },
+
reset() {
this.tableData = []
this.tableHeader = []
@@ -386,11 +612,11 @@
async getPrentOrganization() {
const { data: res } = await PrentOrganization()
this.orgArr = res
- // this.cascaderOptions = arrayToTree(res, {
- // parentProperty: 'parent_id',
- // customID: 'torg_code',
- // childrenProperty: 'children'
- // })
+ this.orgOptions = arrayToTree(res, {
+ parentProperty: 'parent_id',
+ customID: 'torg_code',
+ childrenProperty: 'children'
+ })
},
// 鑾峰彇宀椾綅涓嬫媺鏁扮粍
async getPostPermissions() {
@@ -414,6 +640,9 @@
} else if (column.label.indexOf('*') === -1 && rowIndex === 0) {
string = 'background:#00b0f0;'
}
+ // else if (rowIndex === 0 && columnIndex === 0) {
+ // string = 'background:red;color:#fff'
+ // }
return string + 'padding: 5px 0; fontWeight: 500;'
},
cellStyle() {
@@ -421,6 +650,16 @@
padding: '5px 0'
}
return option
+ },
+ indexRender(h, { column }) {
+ return [
+ h('span', { style: 'color:#FFF' }, column.label)
+ ]
+ },
+ operationRender(h, { column }) {
+ return [
+ h('span', { style: 'color:#FFF' }, column.label)
+ ]
},
addRedStar(h, { column }) {
if (column.label.indexOf('*') !== -1) { // 蹇呭~瀛楁
@@ -439,14 +678,4 @@
}
}
</script>
-
-<style scoped lang="scss">
-//::v-deep .el-table__body-wrapper {
- //overflow-y: auto;
- //overflow-x: scroll !important;
- //height: calc(100% - 34px);
- //width: 100% !important;
-//}
-
-</style>
--
Gitblit v1.9.3