From 38d11c5d99a78a7c65ccb2b24d6f49b97f9c0fdd Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期五, 17 六月 2022 17:27:15 +0800
Subject: [PATCH] 1..完成基础设置:用户清单列表查询、新增、编辑、删除 功能开发
---
src/views/jcsz/zzjg.vue | 130 ++++++++++++++++++++++++-------------------
1 files changed, 73 insertions(+), 57 deletions(-)
diff --git a/src/views/jcsz/zzjg.vue b/src/views/jcsz/zzjg.vue
index beb7b7d..cf1f0fb 100644
--- a/src/views/jcsz/zzjg.vue
+++ b/src/views/jcsz/zzjg.vue
@@ -46,6 +46,7 @@
<el-table
:data="tableData"
border
+ highlight-current-row
:style="{width: 100+'%',height:tableHeight+'px'}"
:header-cell-style="this.$headerCellStyle"
:cell-style="this.$cellStyle"
@@ -130,8 +131,8 @@
top="15vh"
@closed="handleClose"
>
- <el-form ref="dialogForm" :model="dialogForm" label-width="80px">
- <el-form-item label="缁勭粐绫诲瀷" required>
+ <el-form ref="dialogForm" :rules="dialogFormRules" :model="dialogForm" label-width="80px">
+ <el-form-item label="缁勭粐绫诲瀷" prop="OrgType">
<el-radio-group
v-model="dialogForm.OrgType"
style="display: flex;align-items: end;height: 29px;"
@@ -145,13 +146,13 @@
/>
</el-radio-group>
</el-form-item>
- <el-form-item label="缁勭粐缂栫爜" required>
- <el-input v-model="dialogForm.OrgCode" style="width: 220px" />
+ <el-form-item label="缁勭粐缂栫爜" prop="OrgCode">
+ <el-input v-model="dialogForm.OrgCode" :disabled="operation!=='add'" style="width: 220px" />
</el-form-item>
- <el-form-item label="缁勭粐鍚嶇О" required>
+ <el-form-item label="缁勭粐鍚嶇О" prop="OrgName">
<el-input v-model="dialogForm.OrgName" style="width: 220px" />
</el-form-item>
- <el-form-item v-if="dialogFormOrgTypeSelected!=='F'" label="涓婄骇鍗曚綅" required>
+ <el-form-item v-if="dialogFormOrgTypeSelected!=='F'" prop="SupUnit" label="涓婄骇鍗曚綅">
<el-select
v-model="dialogForm.SupUnit"
style="width: 220px"
@@ -159,7 +160,6 @@
>
<el-option
v-for="item in SupUnitArr"
- :key="item.id"
:label="item.org_name"
:value="item.id"
/>
@@ -181,12 +181,31 @@
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
+const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
name: 'Zzjg',
components: {
Pagination
},
data() {
+ const validateName = (rule, value, callback) => {
+ if (!value) {
+ return callback(new Error('璇疯緭鍏ョ紪鐮�'))
+ } else {
+ if (SER_HZ.test(value)) {
+ return callback(new Error('缂栫爜涓嶈兘涓轰腑鏂�'))
+ } else {
+ callback()
+ }
+ }
+ }
+ const validateTypeCode = (rule, value, callback) => {
+ if (!value) {
+ return callback(new Error('璇烽�夋嫨涓婄骇'))
+ } else {
+ callback()
+ }
+ }
return {
mainHeight: 0,
tableHeight: 0,
@@ -219,21 +238,21 @@
},
SupUnitArr: [],
dialogFormOrgTypeSelected: '',
- operation: ''
- // dialogFormRules: {
- // // OrgType: [
- // // { required: true, message: '璇疯緭鍏ュ悕绉�', trigger: 'blur' }
- // // ],
- // OrgCode: [
- // { required: true, message: '璇疯緭鍏ョ粍缁囩紪鐮�', trigger: 'blur' }
- // ],
- // OrgName: [
- // { required: true, message: '璇疯緭鍏ョ粍缁囧悕绉�', trigger: 'blur' }
- // ]
- // // SupUnit: [
- // // { required: true, message: '璇疯緭鍏ュ悕绉�', trigger: 'blur' }
- // // ]
- // }
+ operation: '',
+ dialogFormRules: {
+ OrgType: [
+ { required: true, message: '璇疯緭鍏ラ�夋嫨绫诲瀷', trigger: ['blur', 'change'] }
+ ],
+ OrgCode: [
+ { required: true, validator: validateName, trigger: ['blur', 'change'] }
+ ],
+ OrgName: [
+ { required: true, message: '璇疯緭鍏ュ悕绉�', trigger: ['blur', 'change'] }
+ ],
+ SupUnit: [
+ { required: true, validator: validateTypeCode, trigger: ['blur', 'change'] }
+ ]
+ }
}
},
@@ -246,8 +265,9 @@
},
methods: {
async getOrganizationSearch() {
- const { data: res } = await OrganizationSearch(this.form)
- this.tableData = res
+ const res = await OrganizationSearch(this.form)
+ this.tableData = res.data
+ this.total = res.count
},
// 鎺掑簭鏀瑰彉鏃�
sortChange({ column, prop, order }) {
@@ -312,10 +332,12 @@
} else if (row.description === 'L') {
this.dialogForm.OrgType = '鐢熶骇绾�'
}
- this.changeRadio(this.dialogForm.OrgType)
- this.dialogForm.OrgCode = row.org_code
- this.dialogForm.OrgName = row.org_name
- this.dialogForm.SupUnit = row.parent_id
+ this.$nextTick(() => {
+ this.changeRadio(this.dialogForm.OrgType)
+ this.dialogForm.OrgCode = row.org_code
+ this.dialogForm.OrgName = row.org_name
+ this.dialogForm.SupUnit = row.parent_id
+ })
},
// 鍒犻櫎鎸夐挳
async del(id) {
@@ -340,42 +362,36 @@
this.dialogForm.OrgCode = ''
this.dialogForm.OrgName = ''
this.dialogForm.SupUnit = ''
+ this.$refs.dialogForm.clearValidate()
},
// 瀵硅瘽妗嗗彇娑�
dialogVisibleCancel() {
this.dialogVisible = false
},
// 瀵硅瘽妗嗙‘璁�
- async dialogVisibleConfirm() {
- if (this.dialogFormOrgTypeSelected.length < 1) {
- return this.$message.info('缁勭粐绫诲瀷鏈�夛紒')
- }
- if (this.dialogForm.OrgCode < 1) {
- return this.$message.info('缁勭粐缂栫爜鏈~锛�')
- }
- if (this.dialogForm.OrgName < 1) {
- return this.$message.info('缁勭粐鍚嶇О鏈~锛�')
- }
- if (this.dialogForm.SupUnit < 1) {
- return this.$message.info('涓婄骇鍗曚綅鏈�夛紒')
- }
+ dialogVisibleConfirm() {
+ this.$refs.dialogForm.validate(valid => {
+ if (valid) {
+ const data = {
+ OrganType: this.dialogFormOrgTypeSelected,
+ OrganCode: this.dialogForm.OrgCode,
+ OrganName: this.dialogForm.OrgName,
+ SupUnit: this.dialogFormOrgTypeSelected === 'F' ? '0' : this.dialogForm.SupUnit,
+ OperType: this.operation === 'add' ? 'Add' : 'Update',
+ Operator: getCookie('admin')
+ }
+ AddUpdateOrganization(data).then(res => {
+ if (res.code === '200') {
+ this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+ this.getOrganizationSearch()
+ } else {
+ this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
+ }
+ })
- const data = {
- OrganType: this.dialogFormOrgTypeSelected,
- OrganCode: this.dialogForm.OrgCode,
- OrganName: this.dialogForm.OrgName,
- SupUnit: this.dialogFormOrgTypeSelected === 'F' ? '0' : this.dialogForm.SupUnit,
- OperType: this.operation === 'add' ? 'Add' : 'Update',
- Operator: getCookie('admin')
- }
- const res = await AddUpdateOrganization(data)
- if (res.code === '200') {
- this.$message.success('娣诲姞鎴愬姛锛�')
- await this.getOrganizationSearch()
- } else {
- this.$message.error('娣诲姞澶辫触锛�')
- }
- this.dialogVisible = false
+ this.dialogVisible = false
+ }
+ })
},
// 鑾峰彇椤甸潰楂樺害
getHeight() {
--
Gitblit v1.9.3