国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Element UI form表單及select下拉框?qū)崿F(xiàn)動(dòng)態(tài)添加和刪除

這篇具有很好參考價(jià)值的文章主要介紹了Element UI form表單及select下拉框?qū)崿F(xiàn)動(dòng)態(tài)添加和刪除。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

需求為可動(dòng)態(tài)選擇用戶及部門,并具備回顯功能

結(jié)合antv x6 流程圖,實(shí)現(xiàn)需求,每個(gè)流程圖節(jié)點(diǎn)均可設(shè)置當(dāng)前節(jié)點(diǎn)對應(yīng)審批部門和用戶,部門會(huì)簽節(jié)點(diǎn)可設(shè)置多部門多用戶,動(dòng)態(tài)添加部門及用戶。

當(dāng)前節(jié)點(diǎn)已配置人員部門可回顯,當(dāng)前節(jié)點(diǎn)已配置人員刪除,回顯為空。文章來源地址http://www.zghlxwxcb.cn/news/detail-506105.html

<template>
  <div>
    <el-dialog
      title="設(shè)置"
      :visible.sync="dialogFormVisible"
      width="52%"
      :before-close="handleClose"
      :close-on-click-modal="false"
    >
      <el-form ref="dataForm" :model="dataForm">
        <el-row :gutter="24">
          <el-col :span="8">
            <el-form-item label="當(dāng)前節(jié)點(diǎn):" label-width="120px">
              <div style="font-size: 16px; color: #999; font-weight: 600">
                {{ title }}
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              v-if="[2, 3].includes(type)"
              label="所屬公司:"
              label-width="120px"
            >
              <div style="font-size: 16px; color: #999; font-weight: 600">
                {{ companyName }}
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item
              v-if="type === 3"
              label="項(xiàng)目名稱:"
              label-width="120px"
            >
              <div style="font-size: 16px; color: #999; font-weight: 600">
                {{ projectCompanyName }}
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <div v-for="(item, index) in dataForm.selectForm">
          <el-form-item
            :key="index + '.region'"
            label="選擇部門:"
            :prop="'selectForm.' + index + '.region'"
            :rules="{
              required: true,
              message: '請選擇部門',
              trigger: 'change'
            }"
          >
            <el-select
              v-model="item.region"
              placeholder="請選擇部門"
              clearable
              @change="
                (val) => {
                  changeDeptId(val, index, item)
                }
              "
            >
              <el-option
                v-for="(item, index) in departmentList"
                :key="item.value + index"
                :label="item.label"
                :value="item.value"
                :disabled="
                  title === '部門會(huì)簽'
                    ? selectedDeptId.includes(item.value)
                    : false
                "
              />
            </el-select>
            <i
              v-if="title === '部門會(huì)簽'"
              :class="
                index === 0
                  ? 'el-icon-user-solid solid-btn'
                  : 'el-icon-delete-solid solid-btn'
              "
              @click="depIdListChange(index)"
            ></i>
          </el-form-item>
          <el-form-item
            :key="index + '.name'"
            label="選擇用戶:"
            :prop="'selectForm.' + index + '.name'"
            :rules="{
              required: true,
              message: '請選擇用戶',
              trigger: 'change'
            }"
          >
            <el-select v-model="item.name" placeholder="請選擇用戶" clearable>
              <el-option
                v-for="(item, index) in userList[index]"
                :key="item.value + index"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="handleCheck">確 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'ViewDeails',
  components: {},
  props: {},
  data() {
    return {
      dialogFormVisible: false, // 彈框開關(guān)
      dataForm: {
        selectForm: []
      },
      departmentList: [], // 選擇部門
      userList: {
        0: []
      }, // 選擇用戶
      x: null,
      y: null,
      cell: null,
      e: null,
      view: null,
      title: null,
      id: '',
      changeId: null, // 修改配置參數(shù)
      deptid: [], // 部門列表
      userid: [], //用戶列表
      selectList: [], // 部門會(huì)簽列表
      assigneeName: null, // 節(jié)點(diǎn)常量
      companyName: null, // 所屬公司
      projectCompanyName: null, // 所屬companyName部門名稱
      companyCode: null, // 部門code
      type: null, // 1 - 集團(tuán) 2- 工程 3- 項(xiàng)目工區(qū) 4- 指揮部
      selectedDeptId: [], // 選中的部門id數(shù)組
      userMessage: null // 選擇用戶是否存在
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    // this.constantNode()
  },
  methods: {
    show(
      e,
      x,
      y,
      cell,
      name,
      code,
      projectName,
      projectCode,
      id,
      changeId,
      deptid,
      userid
    ) {
      this.x = x
      this.y = y
      this.cell = cell
      this.id = id
      this.changeId = changeId
      this.companyName = name
      this.companyCode = code
      this.projectCompanyCode = projectCode
      this.projectCompanyName = projectName
      this.title = cell.store.data.attrs.text.text
        ? cell.store.data.attrs.text.text
        : e.target.innerHTML
      this.type = this.$route.query.companyType
      this.dialogFormVisible = true
      this.dataForm.selectForm = []
      this.queryCompanyList()
      // 判斷部門及用戶數(shù)據(jù)是否已配置
      if (deptid || userid) {
        this.depEcho(deptid, userid)
      } else {
        this.dataForm.selectForm.push({
          region: '',
          name: ''
        })
      }
    },

    // 部門回顯  - 函數(shù)提取出來,減少代碼多次調(diào)用,提高性能
    // 當(dāng)前回顯數(shù)據(jù)和數(shù)據(jù)庫當(dāng)前部門下用戶匹配則正確回顯,若當(dāng)前人員已在數(shù)據(jù)庫刪除,則清空回顯數(shù)據(jù)
    depEcho(deptid, userid) {
      this.deptid = deptid.split(',')
      this.userid = userid.split(',')
      for (var i = 0; i < this.deptid.length; i++) {
        const item = this.deptid[i]
        this.dataForm.selectForm.push({
          region: item,
          name: ''
        })
        this.getUserList(item, i, true)
      }
    },

    //  部門改變事件
    changeDeptId(deptId, index, val) {
      this.getSelectedIdList()
      this.getUserList(deptId, index)
      val.name = ''
    },
    // 更新選中部門的id數(shù)組
    getSelectedIdList() {
      this.selectedDeptId = this.dataForm.selectForm.map((item) => {
        return item.region
      })
    },
    // 獲取用戶列表
    async getUserList(deptId, index, isEdit) {
      const res = await this.$api2.processConfiguration.getUserList({
        deptId
      })
      this.$set(this.userList, index, res)
      if (!isEdit) return
      this.userEcho(res,index)
    },
    // 用戶回顯
    userEcho(userList,index) {
      for (let i = 0; i < userList.length; i++) {
        const value = userList[i].value
        if (this.userid.includes(value)) {
          this.dataForm.selectForm[index].name = value
          break
        } else {
          this.dataForm.selectForm[index].name = ''
        }
      }
    },
    // 部門、人員 添加/刪除事件
    depIdListChange(index) {
      if (index === 0) {
        this.dataForm.selectForm.push({ region: '', name: '' })
      } else {
        this.dataForm.selectForm.splice(index, 1)
        this.getSelectedIdList()
      }
      this.userList[index] = []
    },
    //  獲取部門列表
    async queryCompanyList() {
      // type: null // 1 - 集團(tuán) 2- 工程 3- 項(xiàng)目工區(qū) 4- 指揮部
      if (this.type === 1 || this.type === 2) {
        this.departmentList = await this.$api2.processConfiguration.getDeptList(
          {
            companyCode: this.companyCode
          }
        )
      } else if (this.type === 3 || this.type === 4) {
        this.departmentList = await this.$api2.processConfiguration.getDeptList(
          {
            companyCode: this.projectCompanyCode
          }
        )
      }
    },

    // 提交保存節(jié)點(diǎn)配置
    handleCheck() {
      this.constantNode()
      this.$refs.dataForm.validate((valid) => {
        let regionList = [] // 部門會(huì)簽節(jié)點(diǎn) -部門數(shù)據(jù)
        let userList = [] // 部門會(huì)簽節(jié)點(diǎn) -用戶數(shù)據(jù)
        this.dataForm.selectForm.forEach((item) => {
          regionList.push(item.region)
          userList.push(item.name)
        })
        if (valid) {
          this.$api2.processConfiguration
            .saveFlowConfigDetail({
              assigneeName: this.assigneeName,
              deptIds: regionList.toString(),
              flowConfigId: this.id,
              id: this.changeId,
              userIds: userList.toString()
            })
            .then(() => {
              this.dialogFormVisible = false
              this.$message.success('配置成功')
              this.$emit('change', this.x, this.y, this.cell)
            })
            .catch(() => {})
        } else {
          return false
        }
      })
    },
    initData() {
     //  造成多次點(diǎn)擊確定然后打開新增彈框觸發(fā)校驗(yàn)的原因,就是新增了region 和 name 為空,觸發(fā)表單校驗(yàn),關(guān)閉彈框應(yīng)將全部數(shù)據(jù)置空,而不是新增屬性觸發(fā)校驗(yàn)
     // this.dataForm = { selectForm: [{ region: '', name: '' }] }
      this.dataForm = {
        selectForm: []
      }
      this.userList[0] = []
      this.departmentList = []
      this.selectedDeptId = []
      this.$refs.dataForm.clearValidate()
    },
    // 取消按鈕
    handleClose() {
      this.initData()
      this.dialogFormVisible = false
      this.$refs.dataForm.resetFields()
    },
    // 常量節(jié)點(diǎn) - 對應(yīng)后臺常量解析前臺對應(yīng)node節(jié)點(diǎn)
    // type: 1 - 集團(tuán) 2- 工程 3- 項(xiàng)目工區(qū) 4- 指揮部
    // this.$route.query.flowType: 1 - 標(biāo)準(zhǔn)流程配置 2-變更注銷流程
    /* 指揮部變更標(biāo)準(zhǔn)流程和工程公司變更標(biāo)準(zhǔn)流程相同*/
    constantNode() {
      const nodeMapping = {
        1: {
          1: {
            node1: 'groupCompanyAdministratorFormalExaminationAssignee',
            node2: 'groupCompanyExpertCrewList',
            node3: 'groupCompanyDesigningInstituteAdministratorAssignee',
            node4: 'groupCompanyDesigningInstituteAuditorAssignee',
            node5: 'groupCompanyExpertLeaderAssignee',
            node6: 'groupCompanyDesigningInstituteAdministratorAssignee',
            node7: 'groupCompanyDesigningInstituteDeanAssignee',
            node8: 'groupCompanyAdministratorExamineAssignee',
            node9: 'groupCompanyTechnologyMinisterAssignee',
            node10: 'groupCompanyChiefEngineerAssignee',
            node11: 'groupCompanyAdministratorReturnAssignee'
          },
          2: {
            node1: 'changeGroupCompanyAdministratorAssignee',
            node2: 'changeGroupCompanyTechnologyMinisterAssignee',
            node3: 'changeGroupCompanyChiefEngineerAssignee',
            node5: 'changeGroupCompanyAdministratorReturnAssignee'
          }
        },
        2: {
          1: {
            node1: 'engineeringCompanyAdministratorAssignee',
            node3: 'engineeringCompanyDeptCounterSignList',
            node5: 'engineeringCompanyExpertList',
            node6: 'engineeringCompanyAdministratorReturnAssignee',
            node7: 'engineeringCompanySafetyDirectorAssignee',
            node8: 'engineeringCompanyChiefEngineerAssignee'
          },
          2: {
            node1: 'changeEngineeringCompanyAdministratorAssignee',
            node2: 'changeEngineeringCompanyChiefEngineerAssignee',
            node3: 'changeEngineeringCompanyAdministratorReturnAssignee'
          }
        },
        3: {
          1: {
            node1: 'projectInitiatorAssignee',
            node2: 'projectDeptCounterSignList',
            node3: 'projectSafetyDirectorAssignee',
            node4: 'projectChiefEngineerAssignee',
            node5: 'projectManagerAssignee',
            node6: 'projectInformantArchiveAssignee'
          },
          2: {
            node1: 'changeProjectChiefEngineerInitiatorAssignee',
            node2: 'changeProjectManagerAssignee'
          }
        },
        4: {
          1: {
            node1: 'headquartersDeptCounterSignList',
            node2: 'headquartersSafetyDirectorAssignee',
            node3: 'headquartersChiefEngineerAssignee',
            node4: 'headquartersCommanderAssignee',
            node5: 'headquartersAdministratorReturnAssignee'
          },
          2: {
            node1: 'changeEngineeringCompanyAdministratorAssignee',
            node2: 'changeEngineeringCompanyChiefEngineerAssignee',
            node3: 'changeEngineeringCompanyAdministratorReturnAssignee'
          }
        }
      }
      const type = this.type
      const queryFlowType = this.$route.query.flowType
      const node = this.cell.id
      if (
        !nodeMapping[type] ||
        !nodeMapping[type][queryFlowType] ||
        !nodeMapping[type][queryFlowType][node]
      ) {
        return
      }
      this.assigneeName = nodeMapping[type][queryFlowType][node]
    }
  }
}
</script>

<style scoped>
::v-deep .el-form-item__content {
  display: flex;
}
.solid-btn {
  margin-left: 10px;
  cursor: pointer;
  font-size: 16px;
}
</style>

到了這里,關(guān)于Element UI form表單及select下拉框?qū)崿F(xiàn)動(dòng)態(tài)添加和刪除的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • element-ui form表單的動(dòng)態(tài)rules校驗(yàn)

    element-ui form表單的動(dòng)態(tài)rules校驗(yàn)

    在vue 項(xiàng)目中,有時(shí)候可能會(huì)用到element-ui form表單的動(dòng)態(tài)rules校驗(yàn),比如說選擇了哪個(gè)選項(xiàng),然后動(dòng)態(tài)顯示或者禁用等等。 我們可以巧妙的運(yùn)用element-ui form表單里面form-item想的校驗(yàn)規(guī)則來處理(每一個(gè)form-item項(xiàng)都可以單獨(dú)校驗(yàn))。 上代碼: 重點(diǎn)是這個(gè): :rules=“sqyxForm.jtpslx

    2024年02月15日
    瀏覽(23)
  • 【element-ui】form表單動(dòng)態(tài)修改rules校驗(yàn)項(xiàng)

    【element-ui】form表單動(dòng)態(tài)修改rules校驗(yàn)項(xiàng)

    在項(xiàng)目開發(fā)過程中,該頁面有暫存和提交兩個(gè)按鈕,其中暫存和提交必填項(xiàng)校驗(yàn)不一樣,此時(shí)需要?jiǎng)討B(tài)增減必填項(xiàng)校驗(yàn) ,解決方法如下: 增加rules校驗(yàn)項(xiàng) 刪除rules校驗(yàn)項(xiàng)

    2024年02月04日
    瀏覽(34)
  • el-form 動(dòng)態(tài)表單增減項(xiàng) (vue+element ui)

    el-form 動(dòng)態(tài)表單增減項(xiàng) (vue+element ui)

    1、點(diǎn)擊”+“,彈出彈窗,新增一項(xiàng),點(diǎn)擊”-“,刪除當(dāng)前項(xiàng) 代碼展示: html代碼: 注意: el-form-item(表單項(xiàng))循環(huán),綁定的數(shù)組寫在form當(dāng)中 表單: 新增參數(shù)彈框: data: methods: 1、點(diǎn)擊新增,彈出新增彈窗,添加表單項(xiàng) 2、點(diǎn)擊”-“,刪除當(dāng)前表單項(xiàng)

    2024年02月02日
    瀏覽(27)
  • Vue+Element-UI el-form表單動(dòng)態(tài)檢驗(yàn)

    Vue+Element-UI el-form表單動(dòng)態(tài)檢驗(yàn)

    業(yè)務(wù)需求: 表單el-form 有一表單項(xiàng):發(fā)布時(shí)間 ,有5個(gè)選項(xiàng):今天、24小時(shí)、近3天、近7天和自定義時(shí)間,其中當(dāng)選擇自定義時(shí)間時(shí),后面跟著的日期時(shí)間選擇器是必填的,選中其他選項(xiàng)時(shí)則不需要。這就需要做到表單的動(dòng)態(tài)檢驗(yàn)。 最開始實(shí)現(xiàn)方式是在當(dāng)前表單項(xiàng)中設(shè)置規(guī)則

    2024年02月11日
    瀏覽(28)
  • 【vue2+element ui】添加修改共用表單的下拉框回顯問題分析以及解決方案(附共用表單代碼)

    【vue2+element ui】添加修改共用表單的下拉框回顯問題分析以及解決方案(附共用表單代碼)

    簡介 本人前端水平不佳,本文分享在編寫個(gè)人項(xiàng)目前端代碼的時(shí)候遇到的回顯問題的解決辦法,僅供參考。 問題復(fù)原 首先展示表單中的問題代碼,本次前端的設(shè)計(jì)是添加和修改操作共用表單,但是其中有一個(gè)下拉框展示形式,按照慣例通過:value進(jìn)行雙向綁定,保證點(diǎn)擊修改

    2024年02月07日
    瀏覽(25)
  • element UI —— form表單中Radio單選框進(jìn)行切換 & 表單驗(yàn)證rule動(dòng)態(tài)校驗(yàn)-validator & 保存前進(jìn)行form表單校驗(yàn)后才能上傳-validate

    element UI —— form表單中Radio單選框進(jìn)行切換 & 表單驗(yàn)證rule動(dòng)態(tài)校驗(yàn)-validator & 保存前進(jìn)行form表單校驗(yàn)后才能上傳-validate

    element UI —— form表單中Radio單選框進(jìn)行切換 表單驗(yàn)證rule動(dòng)態(tài)校驗(yàn)-validator 保存前進(jìn)行form表單校驗(yàn)后才能上傳-validate 1、效果圖 2、代碼 結(jié)構(gòu) 數(shù)據(jù)

    2024年02月07日
    瀏覽(34)
  • element-ui表單動(dòng)態(tài)添加必填校驗(yàn)

    element-ui表單動(dòng)態(tài)添加必填校驗(yàn)

    業(yè)務(wù)場景:根據(jù)form表單中的某些下拉框選中值,動(dòng)態(tài)切換一些屬性的必填校驗(yàn)。 效果圖: 當(dāng)活動(dòng)區(qū)域非必填時(shí),活動(dòng)名稱取消必填校驗(yàn),否則活動(dòng)名稱必填。

    2024年02月11日
    瀏覽(37)
  • 關(guān)于element ui select,date-picker添加:popper-append-to-body=“false“后,下拉框下拉方向不會(huì)自動(dòng)調(diào)整的問題

    element ui select,date-picker添加 :popper-append-to-body=\\\"false\\\" 后,下拉框下拉方向不會(huì)自動(dòng)調(diào)整; 比如說select的位置處于頁面最下方時(shí),不加 popper-append-to-body=\\\"false\\\" 下拉框會(huì)自動(dòng)向上展開,但是加上 popper-append-to-body=\\\"false\\\" 后下拉框就不會(huì)自動(dòng)向上展開,依然保持默認(rèn)的向下展開,將

    2024年02月15日
    瀏覽(15)
  • Element+Vue實(shí)現(xiàn)動(dòng)態(tài)表單(多個(gè)下拉框組件)

    Element+Vue實(shí)現(xiàn)動(dòng)態(tài)表單(多個(gè)下拉框組件)

    表單的內(nèi)容為巡檢計(jì)劃,巡檢計(jì)劃可以選擇多個(gè)巡檢點(diǎn)位,每個(gè)巡檢點(diǎn)位可以選擇多個(gè)設(shè)備和對應(yīng)操作。 點(diǎn)擊加號圖標(biāo)增加一個(gè)下拉框 減號圖標(biāo)刪除對應(yīng)下拉框 下拉框備選項(xiàng)目相同 點(diǎn)擊設(shè)置動(dòng)作按鈕,彈出可編輯表格,可以為該巡檢點(diǎn)位設(shè)置多個(gè)動(dòng)作 表格每行內(nèi)容可編 設(shè)

    2024年02月15日
    瀏覽(20)
  • element-ui的el-form表單和el-table校驗(yàn)嵌套使用校驗(yàn)el-input和el-select

    element-ui的el-form表單和el-table校驗(yàn)嵌套使用校驗(yàn)el-input和el-select

    場景:前端開發(fā)中,經(jīng)常會(huì)遇到比較多的表單填寫頁面,其中有el-form,el-table,表格的每一列中又嵌套著輸入框或者下拉框,然后每個(gè)還需要做單獨(dú)的校驗(yàn) 效果: ? 點(diǎn)擊保存可校驗(yàn)el-input和el-select是否有值,不符合校驗(yàn)規(guī)則就標(biāo)紅提醒 ? 1.el-form里面嵌套el-table 2.在el-table-column自定義內(nèi)

    2024年02月02日
    瀏覽(32)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包