From 86e5ff7028168bf18b5d3846022ebeac09aa4d4f Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期四, 05 九月 2024 17:11:19 +0800
Subject: [PATCH] 1.处理页面表格错位问题 引入activated() 事件
---
src/views/systemSetting/encodingRules.vue | 930 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 465 insertions(+), 465 deletions(-)
diff --git a/src/views/systemSetting/encodingRules.vue b/src/views/systemSetting/encodingRules.vue
index 6ecf594..7b1cc1a 100644
--- a/src/views/systemSetting/encodingRules.vue
+++ b/src/views/systemSetting/encodingRules.vue
@@ -1,465 +1,465 @@
-<template>
- <div>
- <div class="body" :style="{height:mainHeight+'px'}">
- <div class="bodyTopButtonGroup">
- <el-button
- v-waves
- :style="{visibility:$buttoncode.includes('Add')?'':'hidden'}"
- type="primary"
- icon="el-icon-circle-plus-outline"
- @click="add('add')"
- >鏂板</el-button>
- </div>
-
- <div class="bodyTopFormGroup">
- <el-form
- ref="form"
- :model="form"
- label-width="100px"
- inline
- style="display: flex;"
- >
- <div class="elForm">
- <el-form-item label="鑿滃崟鍚嶇О" style=" display: flex;">
- <el-input v-model="form.rightname" placeholder="璇疯緭鍏�" style="width: 200px" />
- </el-form-item>
- <el-form-item label="鍥哄畾瀛楃" style=" display: flex;">
- <el-input v-model="form.prefix" placeholder="璇疯緭鍏�" style="width: 200px" />
- </el-form-item>
-
- </div>
- <div
- class="bodySearchReset"
- :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
- >
- <el-button v-waves type="primary" icon="el-icon-search" @click="getEncodingRules">鏌ヨ</el-button>
- <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
- </div>
- </el-form>
- <div
- class="bodyTopFormExpand"
- style="height:5px"
- >
- <!-- <svg-icon-->
- <!-- v-show="mouseHoverType==='mouseout'"-->
- <!-- style="cursor: pointer"-->
- <!-- :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
- <!-- @mouseenter="mouseHoverType=$event.type"-->
- <!-- />-->
- <!-- <svg-icon-->
- <!-- v-show="mouseHoverType==='mouseenter'"-->
- <!-- style="cursor: pointer"-->
- <!-- :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
- <!-- @click="isExpandForm=!isExpandForm"-->
- <!-- @mouseout="mouseHoverType=$event.type"-->
- <!-- />-->
- </div>
- </div>
-
- <div class="elTableDiv">
-
- <el-table
- ref="tableDataRef"
- class="tableFixed"
- :data="tableData"
- :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
- border
- row-class-name="custom-row"
- :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
- highlight-current-row
- :header-cell-style="this.$headerCellStyle"
- :cell-style="this.$cellStyle"
- @sort-change="sortChange"
- >
- <el-table-column
- prop="rowNum"
- width="50"
- fixed
- label="搴忓彿"
- />
- <el-table-column
- prop="menucode"
- label="鑿滃崟缂栫爜"
- sortable="custom"
- />
- <el-table-column
- prop="menuname"
- label="鑿滃崟鍚嶇О"
- sortable="custom"
- />
- <el-table-column
- prop="Type"
- label="鑿滃崟绫诲瀷"
- sortable="custom"
- />
- <el-table-column
- prop="prefix"
- label="鍥哄畾瀛楃"
- sortable="custom"
- />
- <el-table-column
- prop="filingdate"
- label="缂栫爜鏍煎紡"
- sortable="custom"
- />
- <el-table-column
- prop="incbit"
- label="鑷浣嶆暟"
- sortable="custom"
- />
- <el-table-column
- prop="value"
- label="娴佹按鍙�"
- width="160"
- sortable="custom"
- />
- <el-table-column
- v-if="$buttoncode.toString().length"
- label="鎿嶄綔"
- width="120"
- fixed="right"
- >
- <template slot-scope="{row}">
- <div class="operationClass">
- <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
- <i
- class="el-icon-edit-outline"
- :style="{color:$store.state.settings.theme,display:$buttoncode.includes('Update')?'':'none'}"
- @click="edit('edit',row)"
- />
- </el-tooltip>
- <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
- <i
- class="el-icon-delete"
- :style="{color:$store.state.settings.theme,display:$buttoncode.includes('Delete')?'':'none'}"
- @click="del(row)"
- />
- </el-tooltip>
- </div>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!--鍒嗛〉-->
- <pagination
- :total="total"
- :page.sync="form.page"
- :limit.sync="form.rows"
- align="right"
- layout="total,prev, pager, next,sizes"
- popper-class="select_bottom"
- @pagination="getEncodingRules"
- />
- </div>
-
- <el-dialog
- v-el-drag-dialog
- :title="operation==='add'?'鏂板':'缂栬緫'"
- :visible.sync="dialogVisible"
- width="800px"
- :close-on-click-modal="false"
- top="15vh"
- @closed="handleClose"
- @close="handleClose"
- >
- <el-form
- ref="dialogForm"
- inline
- :rules="dialogFormRules"
- style="display: flex;flex-direction: column"
- :model="dialogForm"
- label-width="80px"
- >
- <el-form-item label="鑿滃崟绫诲瀷" required>
- <el-radio-group v-model="dialogForm.type" @change="radioChange">
- <el-radio label="PC" name="PC" />
- <el-radio label="APP" name="APP" />
- </el-radio-group>
- </el-form-item>
- <el-form-item label="鑿滃崟鍚嶇О" required>
- <el-cascader
- ref="cascader"
- :options="menuOptions"
- filterable
- :props="defaultProps"
- :show-all-levels="false"
- />
- </el-form-item>
- <el-form-item label="鍥哄畾瀛楃" prop="prefix">
- <el-input v-model="dialogForm.prefix" style="width: 200px" />
- </el-form-item>
- <el-form-item prop="filingdate" label="缂栫爜鏍煎紡">
- <el-select
- v-model="dialogForm.filingdate"
- style="width: 200px"
- placeholder="璇烽�夋嫨"
- :popper-append-to-body="false"
- >
- <el-option
- v-for="item in dateType"
- :key="item.code"
- :label="item.name"
- :value="item.code"
- />
- </el-select>
- </el-form-item>
-
- <el-form-item label="鑷浣嶆暟" prop="incbit" required>
- <el-input v-model="dialogForm.incbit" oninput="value=value.replace(/[^0-9]/g,'')" style="width: 200px" />
- </el-form-item>
-
- <el-form-item label="缂栫爜棰勮">
- {{ encodingPre }}
- <!-- <el-input v-model="dialogForm.OrgName" style="width: 200px" />-->
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <div class="footerButton">
- <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
- <el-button
- v-waves
- type="primary"
- :loading="$store.state.app.buttonIsDisabled"
- :disabled="$store.state.app.buttonIsDisabled"
- @click="dialogVisibleConfirm"
- >纭� 瀹�</el-button>
- </div>
- </span>
- </el-dialog>
-
- </div>
-</template>
-
-<script>
-import Pagination from '@/components/Pagination'
-import { getCookie } from '@/utils/auth'
-import { validateCode } from '@/utils/global'
-import elDragDialog from '@/directive/el-drag-dialog'
-import waves from '@/directive/waves'
-import { CodeMenuSelect, DeleteEncodingRules, EncodingRules, SaveEncodingRules } from '@/api/systemSetting'
-import arrayToTree from 'array-to-tree'
-
-export default {
- name: 'ReportList',
- components: {
- Pagination
- },
- directives: { elDragDialog, waves },
- data() {
- return {
- isExpandForm: false,
- mainHeight: 0,
- tableHeight: 0,
- form: {
- rightname: '', // 缂栫爜鍚嶇О
- prefix: '', // 鍥哄畾瀛楃
- prop: 'lm_date', // 鎺掑簭瀛楁
- order: 'desc', // 鎺掑簭瀛楁
- page: 1, // 绗嚑椤�
- rows: 20 // 姣忛〉澶氬皯鏉�
- },
- total: 10,
- tableData: [],
- dialogVisible: false,
- dialogForm: {
- type: 'PC', // 鑿滃崟绫诲瀷
- rightcode: '', // 鑿滃崟缂栫爜
- rightname: '', // 鑿滃崟鍚嶇О
- incbit: '1', // 鑷浣嶆暟
- filingdate: '', // 缂栫爜鏍煎紡
- prefix: ''// 鍥哄畾瀛楃
- },
- encodingPre: '', // 缂栫爜棰勮
- dateType: [
- { name: '骞存湀鏃�', code: '骞存湀鏃�' },
- { name: '骞存湀', code: '骞存湀' },
- { name: '骞�', code: '骞�' }
- ],
- menuOptionsAll: [],
- menuOptions: [],
- defaultProps: {
- expandTrigger: 'hover',
- value: 'menucode',
- label: 'menuname'
- },
- operation: '',
- dialogFormRules: {
- prefix: [
- { required: true, message: '璇疯緭鍏ュ浐瀹氬瓧绗�', trigger: ['blur', 'change'] }
- ],
- // OrgCode: [
- // { required: true, validator: validateCode, trigger: ['blur', 'change'] }
- // ],
- filingdate: [
- { required: true, message: '璇烽�夋嫨缂栫爜鏍煎紡', trigger: ['blur', 'change'] }
- ],
- incbit: [
- { required: true, message: '璇疯緭鍏ヨ嚜澧炰綅鏁�', trigger: ['blur', 'change'] }
- ]
-
- }
- }
- },
- watch: {
- dialogForm: {
- handler(newValue, oldValue) {
- const date = new Date()
- let newDate = ''
- if (newValue.filingdate === '骞存湀鏃�') {
- newDate = date.getFullYear().toString().substring(2, 4) + '' + (date.getMonth() + 1 + '').padStart(2, '0') + '' + (date.getDate() + '').padStart(2, '0')
- } else if (newValue.filingdate === '骞存湀') {
- newDate = date.getFullYear().toString().substring(2, 4) + '' + (date.getMonth() + 1 + '').padStart(2, '0')
- } else if (newValue.filingdate === '骞�') {
- newDate = date.getFullYear().toString().substring(2, 4) + ''
- }
- this.encodingPre = newValue.prefix + '' + newDate + '' + (1 + '').padStart(newValue.incbit, '0')
- },
- immediate: true,
- deep: true
- }
- },
- created() {
- this.getEncodingRules()
- },
- mounted() {
- window.addEventListener('resize', this.getHeight)
- this.getHeight()
-
- this.getCodeMenuSelect()
- },
- methods: {
- async getCodeMenuSelect() {
- const { data: res } = await CodeMenuSelect()
- this.menuOptionsAll = arrayToTree(res, {
- parentProperty: 'parent_id',
- customID: 'menucode',
- childrenProperty: 'children'
- })
- // this.menuOptions = this.menuOptionsAll.filter(i => i.Type === this.dialogForm.type)
- },
- radioChange() {
- this.menuOptions = this.menuOptionsAll.filter(i => i.Type === this.dialogForm.type)
- },
- async getEncodingRules() {
- const res = await EncodingRules(this.form)
- this.tableData = res.data
- this.total = res.count
- },
- // 鎺掑簭鏀瑰彉鏃�
- sortChange({ column, prop, order }) {
- if (order === 'descending') {
- order = 'desc'
- } else if (order === 'ascending') {
- order = 'asc'
- } else {
- order = 'desc'
- }
- this.form.order = order
- this.form.prop = prop
- this.getEncodingRules()
- },
- // 閲嶇疆
- reset() {
- this.form.rightname = ''
- this.form.prefix = ''
- this.getEncodingRules()
- },
- // 鏂板鎸夐挳
- add(operation) {
- this.operation = operation
- this.dialogVisible = true
- },
- // 淇敼鎸夐挳
- edit(operation, row) {
- this.operation = operation
- this.dialogVisible = true
-
- this.$nextTick(() => {
- this.dialogForm.type = row.Type
- this.radioChange()
-
- let parentCode = ''
- this.menuOptions.forEach(item => {
- if (item.children && item.children.length) {
- item.children.forEach(it => {
- if (it.menucode === row.menucode) {
- parentCode = it.parent_id
- }
- })
- }
- })
- console.log(parentCode, row.menucode)
- this.$refs.cascader.checkedValue = [parentCode, row.menucode]
- this.dialogForm.rightcode = row.menucode
- this.dialogForm.incbit = row.incbit
- this.dialogForm.filingdate = row.filingdate
- this.dialogForm.prefix = row.prefix
- })
- },
- // 鍒犻櫎鎸夐挳
- async del(row) {
- this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
- confirmButtonText: '纭畾',
- cancelButtonText: '鍙栨秷',
- type: 'warning'
- }).then(() => {
- DeleteEncodingRules({ menucode: row.menucode }).then(res => {
- if (res.code === '200') {
- this.$notify.success('鍒犻櫎鎴愬姛!')
- if (this.form.page > 1 && this.tableData.length === 1) {
- this.form.page--
- }
- this.getEncodingRules()
- }
- })
- }).catch(() => {
- this.$notify.info('宸插彇娑堝垹闄�')
- })
- },
- // 瀵硅瘽妗嗗叧闂簨浠�
- handleClose() {
- this.dialogForm.rightcode = ''
- this.dialogForm.rightname = ''
- this.dialogForm.incbit = '1'
- this.dialogForm.filingdate = ''
- this.dialogForm.prefix = ''
- this.$refs.cascader.checkedValue = ''
- this.$refs.dialogForm.clearValidate()
- },
- // 瀵硅瘽妗嗗彇娑�
- dialogVisibleCancel() {
- this.dialogVisible = false
- },
- // 瀵硅瘽妗嗙‘璁�
- dialogVisibleConfirm() {
- this.$refs.dialogForm.validate(valid => {
- if (valid) {
- this.$store.state.app.buttonIsDisabled = true
- const rightcode = this.$refs.cascader.checkedValue[this.$refs.cascader.checkedValue.length - 1]
- this.dialogForm.rightcode = rightcode
- this.dialogForm.rightname = this.menuOptions[this.menuOptions.findIndex(i => i.menucode === this.$refs.cascader.checkedValue[0])].children.find(i => i.menucode === rightcode).menuname
- SaveEncodingRules(this.dialogForm).then(res => {
- if (res.code === '200') {
- this.$notify.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
- this.dialogVisible = false
- this.$store.state.app.buttonIsDisabled = false
- this.getEncodingRules()
- } else {
- this.$store.state.app.buttonIsDisabled = false
- this.$notify.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
- }
- })
- }
- })
- },
- // 鑾峰彇椤甸潰楂樺害
- getHeight() {
- this.$nextTick(() => {
- this.mainHeight = window.innerHeight - 85
- this.tableHeight = this.mainHeight - 240
- this.$refs.tableDataRef.doLayout()
- })
- }
- }
-}
-</script>
+<template>
+ <div>
+ <div class="body" :style="{height:mainHeight+'px'}">
+ <div class="bodyTopButtonGroup">
+ <el-button
+ v-waves
+ :style="{visibility:$buttoncode.includes('Add')?'':'hidden'}"
+ type="primary"
+ icon="el-icon-circle-plus-outline"
+ @click="add('add')"
+ >鏂板</el-button>
+ </div>
+
+ <div class="bodyTopFormGroup">
+ <el-form
+ ref="form"
+ :model="form"
+ label-width="100px"
+ inline
+ style="display: flex;"
+ >
+ <div class="elForm">
+ <el-form-item label="鑿滃崟鍚嶇О" style=" display: flex;">
+ <el-input v-model="form.rightname" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鍥哄畾瀛楃" style=" display: flex;">
+ <el-input v-model="form.prefix" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+
+ </div>
+ <div
+ class="bodySearchReset"
+ :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+ >
+ <el-button v-waves type="primary" icon="el-icon-search" @click="getEncodingRules">鏌ヨ</el-button>
+ <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+ </div>
+ </el-form>
+ <div
+ class="bodyTopFormExpand"
+ style="height:5px"
+ >
+ <!-- <svg-icon-->
+ <!-- v-show="mouseHoverType==='mouseout'"-->
+ <!-- style="cursor: pointer"-->
+ <!-- :icon-class="!isExpandForm?'doubleDown3':'doubleUp3'"-->
+ <!-- @mouseenter="mouseHoverType=$event.type"-->
+ <!-- />-->
+ <!-- <svg-icon-->
+ <!-- v-show="mouseHoverType==='mouseenter'"-->
+ <!-- style="cursor: pointer"-->
+ <!-- :icon-class="!isExpandForm?'doubleDown':'doubleUp'"-->
+ <!-- @click="isExpandForm=!isExpandForm"-->
+ <!-- @mouseout="mouseHoverType=$event.type"-->
+ <!-- />-->
+ </div>
+ </div>
+
+ <div class="elTableDiv">
+
+ <el-table
+ ref="tableDataRef"
+ class="tableFixed"
+ :data="tableData"
+ :height="isExpandForm?tableHeight:(tableHeight+40)+'px'"
+ border
+ row-class-name="custom-row"
+ :style="{width: 100+'%',height:isExpandForm?tableHeight:(tableHeight+40)+'px',}"
+ highlight-current-row
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ @sort-change="sortChange"
+ >
+ <el-table-column
+ prop="rowNum"
+ width="50"
+ fixed
+ label="搴忓彿"
+ />
+ <el-table-column
+ prop="menucode"
+ label="鑿滃崟缂栫爜"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="menuname"
+ label="鑿滃崟鍚嶇О"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="Type"
+ label="鑿滃崟绫诲瀷"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="prefix"
+ label="鍥哄畾瀛楃"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="filingdate"
+ label="缂栫爜鏍煎紡"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="incbit"
+ label="鑷浣嶆暟"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="value"
+ label="娴佹按鍙�"
+ width="160"
+ sortable="custom"
+ />
+ <el-table-column
+ v-if="$buttoncode.toString().length"
+ label="鎿嶄綔"
+ width="120"
+ fixed="right"
+ >
+ <template slot-scope="{row}">
+ <div class="operationClass">
+ <el-tooltip class="item" effect="dark" content="缂栬緫" placement="top">
+ <i
+ class="el-icon-edit-outline"
+ :style="{color:$store.state.settings.theme,display:$buttoncode.includes('Update')?'':'none'}"
+ @click="edit('edit',row)"
+ />
+ </el-tooltip>
+ <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+ <i
+ class="el-icon-delete"
+ :style="{color:$store.state.settings.theme,display:$buttoncode.includes('Delete')?'':'none'}"
+ @click="del(row)"
+ />
+ </el-tooltip>
+ </div>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ <!--鍒嗛〉-->
+ <pagination
+ :total="total"
+ :page.sync="form.page"
+ :limit.sync="form.rows"
+ align="right"
+ layout="total,prev, pager, next,sizes"
+ popper-class="select_bottom"
+ @pagination="getEncodingRules"
+ />
+ </div>
+
+ <el-dialog
+ v-el-drag-dialog
+ :title="operation==='add'?'鏂板':'缂栬緫'"
+ :visible.sync="dialogVisible"
+ width="800px"
+ :close-on-click-modal="false"
+ top="15vh"
+ @closed="handleClose"
+ @close="handleClose"
+ >
+ <el-form
+ ref="dialogForm"
+ inline
+ :rules="dialogFormRules"
+ style="display: flex;flex-direction: column"
+ :model="dialogForm"
+ label-width="80px"
+ >
+ <el-form-item label="鑿滃崟绫诲瀷" required>
+ <el-radio-group v-model="dialogForm.type" @change="radioChange">
+ <el-radio label="PC" name="PC" />
+ <el-radio label="APP" name="APP" />
+ </el-radio-group>
+ </el-form-item>
+ <el-form-item label="鑿滃崟鍚嶇О" required>
+ <el-cascader
+ ref="cascader"
+ :options="menuOptions"
+ filterable
+ :props="defaultProps"
+ :show-all-levels="false"
+ />
+ </el-form-item>
+ <el-form-item label="鍥哄畾瀛楃" prop="prefix">
+ <el-input v-model="dialogForm.prefix" style="width: 200px" />
+ </el-form-item>
+ <el-form-item prop="filingdate" label="缂栫爜鏍煎紡">
+ <el-select
+ v-model="dialogForm.filingdate"
+ style="width: 200px"
+ placeholder="璇烽�夋嫨"
+ :popper-append-to-body="false"
+ >
+ <el-option
+ v-for="item in dateType"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </el-form-item>
+
+ <el-form-item label="鑷浣嶆暟" prop="incbit" required>
+ <el-input v-model="dialogForm.incbit" oninput="value=value.replace(/[^0-9]/g,'')" style="width: 200px" />
+ </el-form-item>
+
+ <el-form-item label="缂栫爜棰勮">
+ {{ encodingPre }}
+ <!-- <el-input v-model="dialogForm.OrgName" style="width: 200px" />-->
+ </el-form-item>
+ </el-form>
+ <span slot="footer" class="dialog-footer">
+ <div class="footerButton">
+ <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
+ <el-button
+ v-waves
+ type="primary"
+ :loading="$store.state.app.buttonIsDisabled"
+ :disabled="$store.state.app.buttonIsDisabled"
+ @click="dialogVisibleConfirm"
+ >纭� 瀹�</el-button>
+ </div>
+ </span>
+ </el-dialog>
+
+ </div>
+</template>
+
+<script>
+import Pagination from '@/components/Pagination'
+import { getCookie } from '@/utils/auth'
+import { validateCode } from '@/utils/global'
+import elDragDialog from '@/directive/el-drag-dialog'
+import waves from '@/directive/waves'
+import { CodeMenuSelect, DeleteEncodingRules, EncodingRules, SaveEncodingRules } from '@/api/systemSetting'
+import arrayToTree from 'array-to-tree'
+
+export default {
+ name: 'ReportList',
+ components: {
+ Pagination
+ },
+ directives: { elDragDialog, waves },
+ data() {
+ return {
+ isExpandForm: false,
+ mainHeight: 0,
+ tableHeight: 0,
+ form: {
+ rightname: '', // 缂栫爜鍚嶇О
+ prefix: '', // 鍥哄畾瀛楃
+ prop: 'lm_date', // 鎺掑簭瀛楁
+ order: 'desc', // 鎺掑簭瀛楁
+ page: 1, // 绗嚑椤�
+ rows: 20 // 姣忛〉澶氬皯鏉�
+ },
+ total: 10,
+ tableData: [],
+ dialogVisible: false,
+ dialogForm: {
+ type: 'PC', // 鑿滃崟绫诲瀷
+ rightcode: '', // 鑿滃崟缂栫爜
+ rightname: '', // 鑿滃崟鍚嶇О
+ incbit: '1', // 鑷浣嶆暟
+ filingdate: '', // 缂栫爜鏍煎紡
+ prefix: ''// 鍥哄畾瀛楃
+ },
+ encodingPre: '', // 缂栫爜棰勮
+ dateType: [
+ { name: '骞存湀鏃�', code: '骞存湀鏃�' },
+ { name: '骞存湀', code: '骞存湀' },
+ { name: '骞�', code: '骞�' }
+ ],
+ menuOptionsAll: [],
+ menuOptions: [],
+ defaultProps: {
+ expandTrigger: 'hover',
+ value: 'menucode',
+ label: 'menuname'
+ },
+ operation: '',
+ dialogFormRules: {
+ prefix: [
+ { required: true, message: '璇疯緭鍏ュ浐瀹氬瓧绗�', trigger: ['blur', 'change'] }
+ ],
+ // OrgCode: [
+ // { required: true, validator: validateCode, trigger: ['blur', 'change'] }
+ // ],
+ filingdate: [
+ { required: true, message: '璇烽�夋嫨缂栫爜鏍煎紡', trigger: ['blur', 'change'] }
+ ],
+ incbit: [
+ { required: true, message: '璇疯緭鍏ヨ嚜澧炰綅鏁�', trigger: ['blur', 'change'] }
+ ]
+
+ }
+ }
+ },
+ watch: {
+ dialogForm: {
+ handler(newValue, oldValue) {
+ const date = new Date()
+ let newDate = ''
+ if (newValue.filingdate === '骞存湀鏃�') {
+ newDate = date.getFullYear().toString().substring(2, 4) + '' + (date.getMonth() + 1 + '').padStart(2, '0') + '' + (date.getDate() + '').padStart(2, '0')
+ } else if (newValue.filingdate === '骞存湀') {
+ newDate = date.getFullYear().toString().substring(2, 4) + '' + (date.getMonth() + 1 + '').padStart(2, '0')
+ } else if (newValue.filingdate === '骞�') {
+ newDate = date.getFullYear().toString().substring(2, 4) + ''
+ }
+ this.encodingPre = newValue.prefix + '' + newDate + '' + (1 + '').padStart(newValue.incbit, '0')
+ },
+ immediate: true,
+ deep: true
+ }
+ },
+ activated() {
window.addEventListener('resize', this.getHeight)
this.getHeight()
},
created() {
+ this.getEncodingRules()
+ },
+ mounted() {
+ window.addEventListener('resize', this.getHeight)
+ this.getHeight()
+
+ this.getCodeMenuSelect()
+ },
+ methods: {
+ async getCodeMenuSelect() {
+ const { data: res } = await CodeMenuSelect()
+ this.menuOptionsAll = arrayToTree(res, {
+ parentProperty: 'parent_id',
+ customID: 'menucode',
+ childrenProperty: 'children'
+ })
+ // this.menuOptions = this.menuOptionsAll.filter(i => i.Type === this.dialogForm.type)
+ },
+ radioChange() {
+ this.menuOptions = this.menuOptionsAll.filter(i => i.Type === this.dialogForm.type)
+ },
+ async getEncodingRules() {
+ const res = await EncodingRules(this.form)
+ this.tableData = res.data
+ this.total = res.count
+ },
+ // 鎺掑簭鏀瑰彉鏃�
+ sortChange({ column, prop, order }) {
+ if (order === 'descending') {
+ order = 'desc'
+ } else if (order === 'ascending') {
+ order = 'asc'
+ } else {
+ order = 'desc'
+ }
+ this.form.order = order
+ this.form.prop = prop
+ this.getEncodingRules()
+ },
+ // 閲嶇疆
+ reset() {
+ this.form.rightname = ''
+ this.form.prefix = ''
+ this.getEncodingRules()
+ },
+ // 鏂板鎸夐挳
+ add(operation) {
+ this.operation = operation
+ this.dialogVisible = true
+ },
+ // 淇敼鎸夐挳
+ edit(operation, row) {
+ this.operation = operation
+ this.dialogVisible = true
+
+ this.$nextTick(() => {
+ this.dialogForm.type = row.Type
+ this.radioChange()
+
+ let parentCode = ''
+ this.menuOptions.forEach(item => {
+ if (item.children && item.children.length) {
+ item.children.forEach(it => {
+ if (it.menucode === row.menucode) {
+ parentCode = it.parent_id
+ }
+ })
+ }
+ })
+ console.log(parentCode, row.menucode)
+ this.$refs.cascader.checkedValue = [parentCode, row.menucode]
+ this.dialogForm.rightcode = row.menucode
+ this.dialogForm.incbit = row.incbit
+ this.dialogForm.filingdate = row.filingdate
+ this.dialogForm.prefix = row.prefix
+ })
+ },
+ // 鍒犻櫎鎸夐挳
+ async del(row) {
+ this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ DeleteEncodingRules({ menucode: row.menucode }).then(res => {
+ if (res.code === '200') {
+ this.$notify.success('鍒犻櫎鎴愬姛!')
+ if (this.form.page > 1 && this.tableData.length === 1) {
+ this.form.page--
+ }
+ this.getEncodingRules()
+ }
+ })
+ }).catch(() => {
+ this.$notify.info('宸插彇娑堝垹闄�')
+ })
+ },
+ // 瀵硅瘽妗嗗叧闂簨浠�
+ handleClose() {
+ this.dialogForm.rightcode = ''
+ this.dialogForm.rightname = ''
+ this.dialogForm.incbit = '1'
+ this.dialogForm.filingdate = ''
+ this.dialogForm.prefix = ''
+ this.$refs.cascader.checkedValue = ''
+ this.$refs.dialogForm.clearValidate()
+ },
+ // 瀵硅瘽妗嗗彇娑�
+ dialogVisibleCancel() {
+ this.dialogVisible = false
+ },
+ // 瀵硅瘽妗嗙‘璁�
+ dialogVisibleConfirm() {
+ this.$refs.dialogForm.validate(valid => {
+ if (valid) {
+ this.$store.state.app.buttonIsDisabled = true
+ const rightcode = this.$refs.cascader.checkedValue[this.$refs.cascader.checkedValue.length - 1]
+ this.dialogForm.rightcode = rightcode
+ this.dialogForm.rightname = this.menuOptions[this.menuOptions.findIndex(i => i.menucode === this.$refs.cascader.checkedValue[0])].children.find(i => i.menucode === rightcode).menuname
+ SaveEncodingRules(this.dialogForm).then(res => {
+ if (res.code === '200') {
+ this.$notify.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+ this.dialogVisible = false
+ this.$store.state.app.buttonIsDisabled = false
+ this.getEncodingRules()
+ } else {
+ this.$store.state.app.buttonIsDisabled = false
+ this.$notify.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
+ }
+ })
+ }
+ })
+ },
+ // 鑾峰彇椤甸潰楂樺害
+ getHeight() {
+ this.$nextTick(() => {
+ this.mainHeight = window.innerHeight - 85
+ this.tableHeight = this.mainHeight - 240
+ this.$refs.tableDataRef.doLayout()
+ })
+ }
+ }
+}
+</script>
--
Gitblit v1.9.3