feature: 选择人员组件添加id

This commit is contained in:
zyn
2023-12-28 10:44:17 +08:00
parent f7969b7d2a
commit 4c8d91a3e6
@@ -2,30 +2,34 @@
<div> <div>
<el-form-item :label="label" :prop="prop" class="add-form-item form-item-disabled"> <el-form-item :label="label" :prop="prop" class="add-form-item form-item-disabled">
<el-input <el-input
:value="value" :value="value"
:placeholder="placeholder" :placeholder="placeholder"
:clearable="clearable" :clearable="clearable"
:disabled="disabled" :disabled="disabled"
readonly readonly
@click.native="choice('role', placeholder, value)"> @click.native="choice('role', placeholder, value)"
></el-input> />
</el-form-item> </el-form-item>
<Role-tree <Role-tree
:is-title="choiceTitle" :is-title="choiceTitle"
:is-visible.sync="modalShowRoleFlag" :is-visible.sync="modalShowRoleFlag"
@checkedRole="checkedRole" :nodeList="nodeList"
:nodeList="nodeList" @checkedRole="checkedRole"
></Role-tree> />
</div> </div>
</template> </template>
<script> <script>
export default { export default {
name: "personFormItem", name: 'PersonFormItem',
props: { props: {
value: { value: {
required: true required: true
}, },
id: {
type: String,
default: ''
},
prop: { prop: {
type: String type: String
}, },
@@ -57,14 +61,14 @@ export default {
handleChange (event) { handleChange (event) {
this.$emit('input', event) this.$emit('input', event)
}, },
choice(type, title, nameId) { choice (type, title, nameId) {
this.nodeList = [] this.nodeList = []
if (nameId) { if (nameId) {
let nameId1 = nameId.split(',') const nameId1 = nameId.split(',')
let idList = [] let idList = []
nameId1.forEach(item => { nameId1.forEach(item => {
let a, b let a, b
a = item.substring(item.indexOf('(') +1) a = item.substring(item.indexOf('(') + 1)
b = a.substring(0, a.lastIndexOf(')')) b = a.substring(0, a.lastIndexOf(')'))
idList.push(b) idList.push(b)
}) })
@@ -75,7 +79,7 @@ export default {
this.choiceTitle = title this.choiceTitle = title
this.modalShowRoleFlag = true this.modalShowRoleFlag = true
}, },
checkedRole(data) { checkedRole (data) {
let idList = '' let idList = ''
let nameList = '' let nameList = ''
data.forEach(item => { data.forEach(item => {
@@ -87,12 +91,13 @@ export default {
nameList += item.name nameList += item.name
}) })
this.$emit('input', nameList) this.$emit('input', nameList)
this.$emit('update:id', idList)
this.$emit('change', { this.$emit('change', {
ids: this.unique(data.map(item => item.topUnitId)).join(","), ids: this.unique(data.map(item => item.topUnitId)).join(','),
names: this.unique(data.map(item => item.topUnit)).join(",") names: this.unique(data.map(item => item.topUnit)).join(',')
}) })
}, },
unique(newArr) { unique (newArr) {
const res = new Map(); const res = new Map();
return newArr.filter((newArr) => !res.has(newArr) && res.set(newArr, 1)); return newArr.filter((newArr) => !res.has(newArr) && res.set(newArr, 1));
}, },