From d71436544198b7b051115662fc9cf4b12ce0cda3 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期二, 19 七月 2022 18:32:40 +0800
Subject: [PATCH] 1.修改bug
---
src/views/zlgl/gxjybz.vue | 259 +++++++++++++++++++++++++++++++++------------------
1 files changed, 166 insertions(+), 93 deletions(-)
diff --git a/src/views/zlgl/gxjybz.vue b/src/views/zlgl/gxjybz.vue
index a8acd3b..8494f30 100644
--- a/src/views/zlgl/gxjybz.vue
+++ b/src/views/zlgl/gxjybz.vue
@@ -54,17 +54,17 @@
label="搴忓彿"
/>
<el-table-column
- prop="org_code"
+ prop="code"
label="鏍囧噯浠g爜"
sortable="custom"
/>
<el-table-column
- prop="org_name"
+ prop="name"
label="鏍囧噯鍚嶇О"
sortable="custom"
/>
<el-table-column
- prop="description"
+ prop="descr"
label="鏍囧噯鎻忚堪"
sortable="custom"
/>
@@ -116,14 +116,14 @@
<i class="el-icon-s-comment" style="color:#42b983;" /> 鏍囧噯淇℃伅锛�
</div>
<el-form ref="dialogForm" style="margin-left: 80px" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
- <el-form-item label="鏍囧噯缂栫爜" prop="OrgCode">
- <el-input v-model="dialogForm.OrgCode" :disabled="operation!=='add'" style="width: 200px" />
+ <el-form-item label="鏍囧噯缂栫爜" prop="code">
+ <el-input v-model="dialogForm.code" :disabled="operation!=='add'" style="width: 200px" />
</el-form-item>
- <el-form-item label="鏍囧噯鍚嶇О" prop="OrgName">
- <el-input v-model="dialogForm.OrgName" style="width: 200px" />
+ <el-form-item label="鏍囧噯鍚嶇О" prop="name">
+ <el-input v-model="dialogForm.name" style="width: 200px" />
</el-form-item>
<el-form-item label="鎻忚堪">
- <el-input v-model="dialogForm.OrgName" type="textarea" style="width: 200px" />
+ <el-input v-model="dialogForm.description" type="textarea" style="width: 200px" />
</el-form-item>
</el-form>
<div style="margin-bottom: 10px">
@@ -145,26 +145,64 @@
@sort-change="sortChange"
>
<el-table-column
- prop="RowNum"
- label="搴忓彿"
+ type="index"
width="100"
/>
<el-table-column
- prop="mc"
- label="妫�楠屾爣鍑嗗悕绉�"
+ prop="code"
+ label="妫�楠屾爣鍑嗙紪鐮�"
>
<template slot-scope="{row}">
- <div v-if="row.isVisible===0">{{ row.mc }}</div>
- <el-input v-if="row.isVisible===1" v-model="row.mc" />
+ <div v-if="row.isVisible===0">{{ row.code }}</div>
+ <el-select
+ v-if="row.isVisible===1"
+ v-model="row.code"
+ filterable
+ :popper-append-to-body="false"
+ style="width: 200px;"
+ placeholder="璇烽�夋嫨"
+ @change="val=>changeCode(val,row)"
+ >
+ <el-option
+ v-for="item in JYSelectArr"
+ :key="item.code"
+ :label="item.code"
+ :value="item.code"
+ />
+ </el-select>
</template>
</el-table-column>
<el-table-column
- prop="ms"
+ prop="name"
+ label="妫�楠屾爣鍑嗗悕绉�"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.isVisible===0">{{ row.name }}</div>
+ <el-select
+ v-if="row.isVisible===1"
+ v-model="row.name"
+ filterable
+ :popper-append-to-body="false"
+ style="width: 200px;"
+ placeholder="璇烽�夋嫨"
+ @change="val=>changeName(val,row)"
+ >
+ <el-option
+ v-for="item in JYSelectArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="descr"
label="妫�楠屾弿杩版弿杩�"
>
<template slot-scope="{row}">
- <div v-if="row.isVisible===0">{{ row.ms }}</div>
- <el-input v-if="row.isVisible===1" v-model="row.ms" />
+ <div v-if="row.isVisible===0">{{ row.descr }}</div>
+ <el-input v-if="row.isVisible===1" v-model="row.descr" />
</template>
</el-table-column>
<el-table-column
@@ -174,29 +212,18 @@
<div class="operationClass">
<el-button v-if="row.isVisible===0" type="text" @click="JYedit(row)">缂栬緫</el-button>
<el-button v-if="row.isVisible===0" type="text" @click="JYdel(row)">鍒犻櫎</el-button>
- <el-button v-if="row.isVisible===1" type="text" @click="JYsave(row)">淇濆瓨</el-button>
- <el-button v-if="row.isVisible===1" type="text" @click="Jycancel(row)">鍙栨秷</el-button>
+ <el-button v-if="row.isVisible===1" type="text" @click="JYsave(row)">纭畾</el-button>
+ <el-button v-if="row.isVisible===1" type="text" @click="JYcancel(row)">鍙栨秷</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
- <!--鍒嗛〉-->
- <!-- <pagination-->
- <!-- v-show="JYtotal>0"-->
- <!-- :total="JYtotal"-->
- <!-- :page.sync="JYfrom.page"-->
- <!-- :limit.sync="JYfrom.rows"-->
- <!-- align="right"-->
- <!-- layout="prev, pager, next,sizes"-->
- <!-- popper-class="select_bottom"-->
- <!-- @pagination="getStepCheckItemSelect"-->
- <!-- />-->
<span slot="footer" class="dialog-footer">
<div class="footerButton">
<el-button @click="dialogVisibleCancel">鍙� 娑�</el-button>
- <el-button type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+ <el-button type="primary" @click="dialogVisibleConfirm">鎻� 浜�</el-button>
</div>
</span>
</el-dialog>
@@ -207,7 +234,7 @@
import Pagination from '@/components/Pagination'
import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
import { getCookie } from '@/utils/auth'
-import { StepCheckStanedSearch } from '@/api/zlgl'
+import { AddUpdateStepCheckStaned, StepCheckItemSelect, StepCheckStanedSearch } from '@/api/zlgl'
const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
@@ -246,46 +273,28 @@
page: 1, // 绗嚑椤�
rows: 20 // 姣忛〉澶氬皯鏉�
},
- OrgTypeArr: [
- { label: '宸ュ巶', value: 'F' },
- { label: '閮ㄩ棬', value: 'D' },
- { label: '杞﹂棿', value: 'W' },
- { label: '绉戝', value: 'K' },
- { label: '鐢熶骇绾�', value: 'L' }
- ],
-
total: 10,
tableData: [],
dialogVisible: false,
dialogForm: {
- OrgType: '',
- OrgCode: '',
- OrgName: '',
- SupUnit: ''// 涓婄骇鍗曚綅
+ code: '', // 宸ュ簭妫�楠屾爣鍑嗙紪鐮�
+ name: '', // 宸ュ簭妫�楠屾爣鍑嗗悕绉�
+ enable: '', // 浼犵┖鍊�
+ description: '' // 宸ュ簭妫�楠屾爣鍑嗘弿杩�
},
operation: '',
dialogFormRules: {
- OrgType: [
- { required: true, message: '璇疯緭鍏ラ�夋嫨绫诲瀷', trigger: ['blur', 'change'] }
- ],
- OrgCode: [
+ code: [
{ required: true, validator: validateName, trigger: ['blur', 'change'] }
],
- OrgName: [
+ name: [
{ required: true, message: '璇疯緭鍏ュ悕绉�', trigger: ['blur', 'change'] }
- ],
- SupUnit: [
- { required: true, validator: validateTypeCode, trigger: ['blur', 'change'] }
]
},
- JYTableData: [
- { RowNum: 1, mc: 'xxx1', ms: 'aaaa' }
- ], // 瀵硅瘽妗嗘楠屼俊鎭〃鏍�
- JYfrom: {
- page: 1,
- rows: 10
- },
- JYtotal: 10
+ JYTableData: [], // 瀵硅瘽妗嗘楠屼俊鎭〃鏍�
+ JYSelectArr: [], // 妫�楠岄」鐩笅鎷夋暟缁�
+ JYSelectedArr: [] // 宸查�夋楠岄」鐩暟缁�
+ // JYAddFlag: true // 鏄惁鍙繘琛屾坊鍔�
}
},
created() {
@@ -324,10 +333,9 @@
},
// 閲嶇疆
reset() {
- this.form.OrgCode = ''
- this.form.OrgName = ''
- this.form.OrgType = ''
- this.form.UserName = ''
+ this.form.stanedcode = ''
+ this.form.stanedname = ''
+ this.form.staneddescr = ''
this.getStepCheckStanedSearch()
},
@@ -342,9 +350,9 @@
this.dialogVisible = true
this.$nextTick(() => {
- this.dialogForm.OrgCode = row.org_code
- this.dialogForm.OrgName = row.org_name
- this.dialogForm.SupUnit = row.parent_id
+ this.dialogForm.OrgCode = row.code
+ this.dialogForm.OrgName = row.name
+ this.dialogForm.SupUnit = row.descr
})
},
// 鏌ョ湅
@@ -371,10 +379,12 @@
},
// 瀵硅瘽妗嗗叧闂簨浠�
handleClose() {
- this.dialogForm.OrgType = ''
- this.dialogForm.OrgCode = ''
- this.dialogForm.OrgName = ''
- this.dialogForm.SupUnit = ''
+ this.dialogForm.code = ''
+ this.dialogForm.name = ''
+ this.dialogForm.enable = ''
+ this.dialogForm.description = ''
+ this.JYTableData = []
+ this.JYSelectedArr = []
this.$refs.dialogForm.clearValidate()
},
// 瀵硅瘽妗嗗彇娑�
@@ -383,15 +393,25 @@
},
// 瀵硅瘽妗嗙‘璁�
dialogVisibleConfirm() {
+ console.log(this.JYSelectedArr.map(i => i))
this.$refs.dialogForm.validate(valid => {
if (valid) {
+ const tableData = []
+ this.JYTableData.forEach((item, index) => {
+ tableData.push({
+ STEPCHECKITEM_SEQ: (index + 1),
+ STEPCHECKITEM_CODE: item.code,
+ STEPCHECKITEM_DESC: item.descr
+ })
+ })
const data = {
- OrganCode: this.dialogForm.OrgCode,
- OrganName: this.dialogForm.OrgName,
- OperType: this.operation === 'add' ? 'Add' : 'Update',
- Operator: getCookie('admin')
+ code: this.dialogForm.code,
+ name: this.dialogForm.name,
+ description: this.dialogForm.description,
+ enable: '',
+ Data: tableData
}
- AddUpdateOrganization(data).then(res => {
+ AddUpdateStepCheckStaned(this.operation === 'add' ? 'Add' : 'Update', data).then(res => {
if (res.code === '200') {
this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
this.dialogVisible = false
@@ -410,25 +430,42 @@
this.tableHeight = this.mainHeight - 100
})
},
-
- // 鑾峰彇妫�楠岄」淇℃伅琛�
- getStepCheckItemSelect() {
- // let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
- // number = number === 0 ? (10 + Math.random()) : number
- this.JYTableData.forEach(item => {
- item.isVisible = 0
- })
+ // 鑾峰彇妫�楠岄」鐩笅鎷夊垪琛�
+ async getStepCheckItemSelect() {
+ const { data: res } = await StepCheckItemSelect()
+ this.JYSelectArr = res
+ },
+ // 妫�楠屾爣鍑嗙紪鐮佸�兼敼鍙�
+ changeCode(val, row) {
+ console.log(this.JYSelectedArr.map(i => i))
+ row.name = this.JYSelectArr.find(it => it.code === val).name
+ row.descr = this.JYSelectArr.find(it => it.code === val).descr
+ },
+ // 妫�楠屾爣鍑嗗悕绉板�兼敼鍙�
+ changeName(val, row) {
+ row.code = this.JYSelectArr.find(it => it.code === val).code
+ row.descr = this.JYSelectArr.find(it => it.code === val).descr
},
// 妫�楠屾柊澧�
JYadd() {
+ if (this.JYTableData.length > 0 && this.JYTableData[this.JYTableData.length - 1].isVisible === 1) {
+ return this.$message.info('璇峰厛纭畾鎴栧彇娑堟湰鏉¤褰曪紒')
+ }
+
let number = Math.random() * Math.random()// 浣滀负鍒犻櫎鏃剁殑鏍囪瘑绗�
number = number === 0 ? (10 + Math.random()) : number
- const data = { mc: '', ms: '', isVisible: 1, number }
- this.JYTableData.unshift(data)
+ const data = { code: '', name: '', descr: '', isVisible: 1, number }
+ this.JYTableData.push(data)
},
JYedit(row) {
+ this.JYSelectedArr.forEach((item, index) => {
+ if (item === row.code) {
+ this.JYSelectedArr.splice(index, 1)
+ }
+ })
+
this.JYTableData.forEach((item, index) => {
- if (item.mc === row.mc) {
+ if (item.code === row.code) {
item.isVisible = 1
}
})
@@ -439,18 +476,48 @@
this.JYTableData.splice(index, 1)
}
})
- },
- JYsave(row) {
- this.JYTableData.forEach(item => {
- if (item.number === row.number) {
- item.isVisible = 0
+
+ this.JYSelectedArr.forEach((item, index) => {
+ if (item === row.code) {
+ this.JYSelectedArr.splice(index, 1)
}
})
},
- Jycancel(row) {
+ JYsave(row) {
+ if (row.code === '') {
+ return this.$message.info('妫�楠屾爣鍑嗕唬鐮佷笉鑳戒负绌猴紒')
+ }
+ if (row.name === '') {
+ return this.$message.info('妫�楠屾爣鍑嗗悕绉颁笉鑳戒负绌猴紒')
+ }
+
+ if (this.JYSelectedArr.find(item => item === row.code) !== undefined) {
+ return this.$message.info('妫�楠屾爣鍑嗕唬鐮佷笉鑳介噸澶嶏紒')
+ } else {
+ this.JYSelectedArr.push(row.code)
+ }
+ // if (row.code === this.JYTableData.find(item => item.code).code) {
+ // return this.$message.info('妫�楠屾爣鍑嗕唬鐮佷笉鑳介噸澶嶏紒')
+ // }
+
+ this.JYTableData.forEach((item, index) => {
+ if (item.number === row.number) {
+ item.isVisible = 0
+ this.JYTableData.splice(index, 1, { number: row.number, code: row.code, name: row.name, isVisible: 0, descr: row.descr })
+ }
+ })
+ console.log(this.JYTableData, 898989)
+ },
+ JYcancel(row) {
this.JYTableData.forEach((item, index) => {
if (item.number === row.number) {
this.JYTableData.splice(index, 1)
+ }
+ })
+
+ this.JYSelectedArr.forEach((item, index) => {
+ if (item === row.code) {
+ this.JYSelectedArr.splice(index, 1)
}
})
}
@@ -621,4 +688,10 @@
border-color: $main_color;
}
+::v-deep .el-select__caret{
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
</style>
--
Gitblit v1.9.3