lyh
2025-06-23 266db48e639ce2cd84572c8586876d906b8ce6b8
src/views/mdc/base/DeliveryGroupUtilizationRateChart.vue
@@ -28,7 +28,7 @@
          <a-col :md="8" :sm="8">
            <a-form-item label="配送小组">
              <a-select v-model="teamCodes" placeholder="请选择配送小组" mode="multiple" :maxTagCount="3"
              <a-select :value="teamCodes" placeholder="请选择配送小组" mode="multiple" :maxTagCount="3"
                        @change="handleDeliverGroupSelectChange" allowClear>
                <a-select-option v-for="item in deliveryGroupList" :key="item.key">{{ item.title }}</a-select-option>
              </a-select>
@@ -45,7 +45,6 @@
          <a-col :md="2" :sm="2">
            <a-space>
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <!--              <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>-->
            </a-space>
          </a-col>
        </a-row>
@@ -73,9 +72,9 @@
      },
      productionIds: [],//班组
      teamCodes: [],//配送小组
      centerList: [],
      groupList: [],
      deliveryGroupList: []
        centerList: [],//中心列表
        groupList: [],//班组列表
        deliveryGroupList: []//配送小组列表
    }
  },
  mounted() {
@@ -247,13 +246,14 @@
     * @param isInitLoad 是否为初始化加载
     */
    getGroupListByApi(productionId, isInitLoad = false) {
        this.groupList = []
      const that = this
      mdcApi.getCenterOrGroupListApi(productionId)
        .then(res => {
          if (res.success) {
            that.groupList = res.result
              that.groupList = res.result ? res.result : []
              that.handleGroupSelectChange(res.result && res.result.length > 0 && isInitLoad ? [res.result[0].value] : [])
            if (!isInitLoad) return
            that.handleGroupSelectChange([res.result[0].value])
            that.loadData()
          }
        })
@@ -265,17 +265,18 @@
     * @param isReduceSelectOption 是否减少班组选中项
     */
    getDeliveryGroupListByApi(productionId, isReduceSelectOption = false) {
        this.deliveryGroupList = []
      const that = this
      mdcApi.getDeliveryGroupListApi(productionId)
        .then(res => {
          if (res.success) {
            that.deliveryGroupList = res.result
              that.deliveryGroupList = res.result ? res.result : []
              // 仅减少勾选项时才进行下一步
            if (!isReduceSelectOption) return
            that.teamCodes.forEach((key, keyIndex, self) => {
              // 如果将唯一一组包含选中配送小组项的班组取消勾选后应将已勾选的配送小组一并取消勾选
              if (that.deliveryGroupList.findIndex(item => item.key === key) === -1) self.splice(keyIndex, 1)
            })
              // 保留改变后的配送小组列表中之前已勾选的配送小组
              const filterTeamCodes = that.teamCodes.filter(item => that.deliveryGroupList.map(item => item.key).includes(item))
              that.handleDeliverGroupSelectChange(filterTeamCodes)
          }
        })
    },
@@ -285,16 +286,6 @@
     * @param value 改变后的中心Id
     */
    handleCenterSelectChange(value) {
      if (this.productionIds.length > 0) {
        this.groupList = []
        this.productionIds = []
        delete this.queryParam.productionIds
      }
      if (this.teamCodes.length > 0) {
        this.deliveryGroupList = []
        this.teamCodes = []
        delete this.queryParam.teamCodes
      }
      this.getGroupListByApi(value)
    },
@@ -316,6 +307,7 @@
     * @param value 改变后的配送小组Id
     */
    handleDeliverGroupSelectChange(value) {
        this.teamCodes = value
      this.queryParam.teamCodes = value.join(',')
    },