agent.vue 2.13 KB
Newer Older
huhaiiqng's avatar
huhaiiqng committed
1 2
<template>
  <div>
huhaiqing's avatar
huhaiqing committed
3
    <el-form ref="agentForm" :model="agentObj" :rules="rules" label-width="120px">
4
      <el-form-item :label="$t('代理商Agent')" prop="agentId">
5 6
        <supplierOutSelect v-model="agentObj.agentId" :companyType="'1'" :areaType="1" :placeholder="$t('请选择代理商')" :allSupplier="this.$attrs.allSupplier" />
        <el-button v-hasPermi="['ecw:supplier:query']" type="text" style="font-size: 13px; margin-left: 240px;" @click="SupplierDetail">{{$t('查看代理商详情')}}</el-button>
huhaiiqng's avatar
huhaiiqng committed
7 8 9
      </el-form-item>
    </el-form>
    <el-row class="operate-button">
10 11
      <el-button type="success" @click="onSubmit">{{$t('提交')}}</el-button>
      <el-button @click="cancel">{{$t('关闭')}}</el-button>
huhaiiqng's avatar
huhaiiqng committed
12 13 14 15 16
    </el-row>
  </div>
</template>

<script>
huhaiqing's avatar
huhaiqing committed
17
import { agentSet } from "@/api/ecw/boxSea";
18
import supplierOutSelect from "./common/supplierOutSelect.vue";
huhaiqing's avatar
huhaiqing committed
19
import { formatStringNumber, serviceMsg } from "../utils";
huhaiqing's avatar
huhaiqing committed
20 21 22
/**
 * agent
 */
huhaiiqng's avatar
huhaiiqng committed
23 24
export default {
  name: "agent",
huhaiqing's avatar
huhaiqing committed
25
  inheritAttrs: false,
26
  components: { supplierOutSelect },
huhaiiqng's avatar
huhaiiqng committed
27 28
  data() {
    return {
huhaiqing's avatar
huhaiqing committed
29
      // agent对象
huhaiqing's avatar
huhaiqing committed
30
      agentObj: {},
huhaiqing's avatar
huhaiqing committed
31 32
      // 校验
      rules: {
33
        agentId: [{ required: true, message: this.$t("必填"), trigger: "change" }],
huhaiqing's avatar
huhaiqing committed
34
      },
35
      supplierId: 0
huhaiiqng's avatar
huhaiiqng committed
36 37
    };
  },
huhaiqing's avatar
huhaiqing committed
38 39 40 41 42 43 44
  created() {
    const { currNode, shipmentObj } = this.$attrs;
    const voName = currNode.voName;
    let oldData = { ...shipmentObj[voName] };
    oldData = formatStringNumber(oldData, ["agentId"]);
    this.agentObj = oldData;
  },
huhaiiqng's avatar
huhaiiqng committed
45
  methods: {
huhaiqing's avatar
huhaiqing committed
46
    /** 提交 */
huhaiiqng's avatar
huhaiiqng committed
47 48 49
    onSubmit() {
      this.$refs["agentForm"].validate((valid) => {
        if (valid) {
huhaiqing's avatar
huhaiqing committed
50 51 52 53 54
          agentSet({
            shipmentId: this.$attrs.shipmentObj.id,
            ...this.agentObj,
          }).then((res) => {
            serviceMsg(res, this).then(() => {
huhaiqing's avatar
huhaiqing committed
55
              this.cancel("submit");
huhaiqing's avatar
huhaiqing committed
56 57
            });
          });
huhaiiqng's avatar
huhaiiqng committed
58 59 60
        }
      });
    },
huhaiqing's avatar
huhaiqing committed
61
    /** 取消 */
huhaiqing's avatar
huhaiqing committed
62 63
    cancel(type) {
      this.$emit("closeDialog", type);
huhaiiqng's avatar
huhaiiqng committed
64
    },
65 66 67 68
    SupplierDetail(){
      this.supplierId = this.agentObj.agentId
      this.$router.push('/supplier/detail?id='+this.supplierId)
    },
huhaiiqng's avatar
huhaiiqng committed
69 70 71 72 73 74
  },
};
</script>

<style lang="scss" scoped>
</style>