agent.vue 1.74 KB
Newer Older
huhaiiqng's avatar
huhaiiqng committed
1 2
<template>
  <div>
huhaiqing's avatar
huhaiqing committed
3 4
    <el-form ref="agentForm" :model="agentObj" :rules="rules" label-width="120px">
      <el-form-item label="代理商Agent" prop="agentId">
huhaiqing's avatar
huhaiqing committed
5
        <supplierSelect v-model="agentObj.agentId" :companyType="'1'" placeholder="请选择代理商" :allSupplier="this.$attrs.allSupplier" />
huhaiiqng's avatar
huhaiiqng committed
6 7 8
      </el-form-item>
    </el-form>
    <el-row class="operate-button">
huhaiqing's avatar
huhaiqing committed
9 10
      <el-button type="success" @click="onSubmit">提交</el-button>
      <el-button @click="cancel">关闭</el-button>
huhaiiqng's avatar
huhaiiqng committed
11 12 13 14 15
    </el-row>
  </div>
</template>

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

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