addDialog.vue 2.41 KB
<!--
 * @Author: 前端 qianduan01@didihu.com.cn
 * @Date: 2024-09-06 09:49:46
 * @LastEditors: 前端 qianduan01@didihu.com.cn
 * @LastEditTime: 2024-09-24 10:18:44
 * @FilePath: \dj-car-life-system\src\views\contentManager\packageConfig\components\addDialog.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 月度库存结算单弹窗 -->
<template>
  <d2-dialog
    title="新增门店"
    :is-visible="dialogVisible"
    class="dailog-box"
    width="36%"
    @closeDialog="handleClose"
    @confirmDialog="handleConfirm"
  >
    <div v-loading="loading">
      <div class="dialog-title">
        请选择新增门店,新增门店的素材会复用默认门店的素材,可自定义修改
      </div>
      <el-select
        filterable
        class="form-select"
        v-model="formData.merchantId"
        placeholder="请选择"
      >
        <el-option
          v-for="(i, indx) in merchantIdList"
          :key="i.merchantId"
          :label="i.merchantName"
          :value="i.merchantId"
        ></el-option>
      </el-select>
    </div>
  </d2-dialog>
</template>

<script>
import { recepitonUpdate } from "@api/contentManager"
import { mapState, mapActions } from "vuex"
export default {
  name: "addDialog",
  data() {
    return {
      formData: {},
      loading: false
    }
  },
  props: {
    dialogVisible: Boolean
  },
  computed: {
    ...mapState("d2admin/merchant", ["merchantIdList"])
  },
  async mounted() {
    this.loading = true
    await this.getMerchantIdList()
    this.loading = false
  },
  methods: {
    ...mapActions("d2admin/merchant", ["getMerchantIdList"]),
    handleConfirm() {
      const { merchantId } = this.formData
      if (!merchantId) {
        return this.$message.error("请选择门店")
      }
      const merchantName = this.merchantIdList.find(
        (i) => i.merchantId === merchantId
      ).merchantName
      recepitonUpdate({ merchantId, configType: 0, merchantName }).then(
        (res) => {
          if (res) {
            this.handleClose()
            this.$message.success("新增成功")
          }
        }
      )
    },
    handleClose() {
      this.$emit("dialogClose")
    }
  }
}
</script>
<style lang="scss">
.dialog-title {
  font-size: 14px;
  line-height: 30px;
  margin-bottom: 15px;
}
.form-select {
  width: 50%;
}
</style>