|
@@ -0,0 +1,102 @@
|
|
|
+<template>
|
|
|
+ <el-form :model="formValues" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic">
|
|
|
+ <el-form-item
|
|
|
+ v-for="(tag, index) in formValues.tags"
|
|
|
+ :label="'标注' + index"
|
|
|
+ :key="tag.key"
|
|
|
+ :prop="'tags.' + index + '.value'"
|
|
|
+ >
|
|
|
+ <div class="d-flex">
|
|
|
+ <el-input v-model="tag.value" placeholder="请输入标注"></el-input>
|
|
|
+ <m-button v-if="formValues.tags.length > 1" class="ml-3" @click.prevent="onRemove(index)">删除</m-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <m-button @click="onAdd">新增标注</m-button>
|
|
|
+ <m-button type="orange" @click="onSave">保存</m-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ saveLabelAll,
|
|
|
+ getLabelPage
|
|
|
+} from '@/api/system'
|
|
|
+export default {
|
|
|
+ name: 'organizationEditLabel',
|
|
|
+ props: {
|
|
|
+ item: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({})
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ formValues: {
|
|
|
+ tags: [
|
|
|
+ { value: null, key: Date.now() }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.onInit()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async onInit () {
|
|
|
+ try {
|
|
|
+ const { data } = await getLabelPage({
|
|
|
+ entity: {
|
|
|
+ labelEntityId: this.item.id
|
|
|
+ },
|
|
|
+ page: {
|
|
|
+ current: 1,
|
|
|
+ size: 1000
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (data.total === 0) {
|
|
|
+ this.formValues.tags = [
|
|
|
+ { value: null, key: Date.now() }
|
|
|
+ ]
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.formValues.tags = data.records.map((e, index) => {
|
|
|
+ return {
|
|
|
+ value: e.labelTitle,
|
|
|
+ key: `${Date.now()}_${index}`
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onRemove (index) {
|
|
|
+ this.formValues.tags.splice(index, 1)
|
|
|
+ },
|
|
|
+ onAdd () {
|
|
|
+ this.formValues.tags.push({
|
|
|
+ value: '',
|
|
|
+ key: Date.now()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ async onSave () {
|
|
|
+ try {
|
|
|
+ await saveLabelAll({
|
|
|
+ labelType: 0,
|
|
|
+ labelTitle: this.formValues.tags.filter(e => e.value).map(e => e.value),
|
|
|
+ labelEntityId: this.item.id
|
|
|
+ })
|
|
|
+ this.$message.success('保存成功')
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+
|
|
|
+</style>
|