yangfeng
2023-07-19 23d80c1b64f23ede237ab8e89ebc2ee2aaf43f26
src/views/service/serviceContract/AddServiceContractDialog.vue
@@ -1,7 +1,7 @@
<template>
  <div class="service-contract">
  <div class="add-service-contract">
    <el-dialog
      :title="editCommonConfig.title + '客户管理'"
      :title="editCommonConfig.title + '服务合同'"
      :visible.sync="editConfig.visible"
      :width="dialogWidth"
      :before-close="handleClose"
@@ -164,8 +164,21 @@
            <el-row>
              <el-col :span="12">
                <el-form-item label="附件" prop="">
                  <template slot="label">
                    <div style="display: flex; float: right">
                      <div style="font-size: 16px">
                        <i class="el-icon-warning-outline" title="最多上传20个附件,最大限制5MB"></i>
                      </div>
                      <span style="margin-left: 5px">附件</span>
                    </div>
                  </template>
                  <div class="annex-view">
                    <div @click="addAnnexClick">添加</div>
                    <div @click="addAnnexClick">
                      <div style="display: flex; float: right">
                        <div style="font-size: 16px"><i class="el-icon-paperclip"></i></div>
                        <span>添加</span>
                      </div>
                    </div>
                    <div class="setFormat" @click="setFormatClick">设置允许上传的文件格式</div>
                  </div>
                </el-form-item>
@@ -183,50 +196,9 @@
              </el-select>
            </div>
          </div>
          <div class="basic-info-view">
            <el-form ref="form" :model="productTableList" :show-message="false" label-position="right">
              <el-table :data="productTableList.tableData" style="width: 100%">
                <el-table-column prop="id" label="#" width="30"></el-table-column>
                <el-table-column prop="productName" label="产品名称">
                  <template slot-scope="scope">
                    <el-form-item
                      label=" "
                      :prop="'productTableList.tableData.' + scope.$index + '.productName'"
                      :rules="[{ required: true, message: '输入不能为空' }]"
                    >
                      <el-input
                        v-model.trim="scope.row.productName"
                        maxlength="50"
                        size="mini"
                        style="width: 60px"
                      ></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column prop="productNumber" label="产品编号"></el-table-column>
                <el-table-column prop="startDate" label="服务开始日">
                  <el-form-item
                    label=" "
                    prop="'productTableList.tableData.' + scope.$index + '.startDate'"
                    :rules="[{ required: true, message: '输入不能为空' }]"
                  >
                    <el-date-picker v-model="scope.row.startDate" type="date" placeholder="选择日期"> </el-date-picker>
                  </el-form-item>
                </el-table-column>
                <el-table-column prop="address" label="服务到期日"> </el-table-column>
                <el-table-column prop="productNumber" label="数量"></el-table-column>
                <el-table-column prop="name" label="含税单价"> </el-table-column>
                <el-table-column prop="address" label="不含税单价"> </el-table-column>
                <el-table-column prop="productNumber" label="折扣率(%)"></el-table-column>
                <el-table-column prop="name" label="折扣额"> </el-table-column>
                <el-table-column prop="address" label="税(销售)"> </el-table-column>
                <el-table-column prop="productNumber" label="实际含税单价"></el-table-column>
                <el-table-column prop="name" label="价税合计"> </el-table-column>
                <el-table-column prop="address" label="描述"> </el-table-column>
              </el-table>
            </el-form>
          <div class="product-view">
            <CommonFormTableView :show-summary="showSummary" :product-table-list="productTableList" />
          </div>
          <!-- 选择审批流程 -->
          <div class="basic-info-title">选择审批流程</div>
          <div class="basic-info-view">
@@ -254,6 +226,7 @@
                  <el-input v-model="editConfig.infomation.approvalSteps"></el-input>
                </el-form-item>
              </el-col>
              \
              <el-col :span="20">
                <el-form-item label="审批人" prop="approvalPerson">
                  <el-input v-model="editConfig.infomation.approvalPerson"></el-input>
@@ -280,6 +253,9 @@
<script>
import CommonSelectView from "@/components/makepager/CommonSelectView"
import CommonFormTableView from "@/components/makepager/CommonFormTableView"
import { getAllData } from "@/api/client/client"
import { getAddSubOrder, getUpdateSubOrder } from "@/api/sales/subOrder"
export default {
  name: "AddServiceContractDialog",
  props: {
@@ -289,32 +265,12 @@
        return {
          visible: false,
          title: "新建",
          infomation: {
            customName: "",
            serviceContractNumber: "AC6521",
            owner: "5",
            contactName: "",
            salesOpportunity: "",
            contractOrder: "",
            quotation: "",
            contractType: "",
            signDate: "",
            startDate: "",
            endDate: "",
            contractStatus: "",
            serviceNumber: "",
            termsTreaty: "",
            notes: "",
            approvalWorkflow: "",
            approvalSteps: "",
            approvalPerson: "",
            approvalOpinion: ""
          }
          infomation: {}
        }
      }
    }
  },
  components: { CommonSelectView },
  components: { CommonSelectView, CommonFormTableView },
  computed: {
    searchCommonHeight() {
      return this.$refs.searchCommonView.offsetHeight
@@ -327,19 +283,8 @@
      rules: {
        serviceContractNumber: [{ required: true, message: "请输入服务合同编号", trigger: "blur" }],
        signDate: [{ required: true, message: "请选择", trigger: "change" }],
        owner: [{ required: true, message: "请选择负责人", trigger: "change" }],
        approvalOpinion: [{ required: true, message: "请输入审批意见", trigger: "blur" }]
        owner: [{ required: true, message: "请选择负责人", trigger: "change" }]
      },
      businessSourceOptions: [
        { value: "1", label: "后台注册" },
        { value: "2", label: "代理商客户" },
        { value: "3", label: "电话陌生拜访" },
        { value: "4", label: "直接访问" },
        { value: "5", label: "项目合作" },
        { value: "6", label: "个人自找" },
        { value: "7", label: "二次销售" },
        { value: "8", label: "公司电话" }
      ],
      ownerOptions: [
        // 负责人
        { value: "1", label: "BOSS" },
@@ -358,35 +303,144 @@
        { value: "3", label: "欧元(€)" }
      ], // 币种
      approvalWorkflowOptions: [], // 审批流程
      productTableList: {
        tableData: [
          {
            id: "1",
            productNumber: "123",
            date: "2016-05-02",
            name: "王小虎",
            address: "上海市普陀区金沙江路 1518 弄"
          }
        ]
      productTableList: {},
      showSummary: {
        show: true,
        total: true,
        sumProp: ["other1", "other2", "other3", "other4"],
        mergeNumber: 3
      }
    }
  },
  created() {},
  created() {
    this.setTableForm()
    this.getCommonData()
  },
  methods: {
    getCommonData() {
      getAllData()
        .then((res) => {
          this.memberOptions = res.data.member
        })
        .catch((err) => {
          console.log(err)
        })
    },
    // 保存
    saveClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.editConfig.infomation)
          const params = this.saveParams()
          console.log(params)
          if (this.editConfig.title === "新建") {
            getAddSubOrder(params)
              .then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message({
                    message: "添加成功",
                    type: "success"
                  })
                  this.$parent.getData()
                }
              })
              .catch((err) => {
                console.log(err)
              })
          } else {
            getUpdateSubOrder(params)
              .then((res) => {
                console.log(res)
                this.editConfig.visible = false
                if (res.code === 200) {
                  this.$message({
                    message: "编辑成功",
                    type: "success"
                  })
                  this.$parent.getData()
                }
              })
              .catch((err) => {
                console.log(err)
              })
          }
        } else {
          console.log("error submit")
          return false
        }
      })
    },
    saveParams() {
      let data = this.editConfig.infomation
      let params = {
        id: this.editConfig.title === "新建" ? 0 : data.id,
        clientId: data.clientId || 0,
        masterOrderId: data.masterOrderId || 0,
        memberId: data.memberId || 0,
        number: data.number || "",
        product: [
          {
            amount: 0,
            desc: "",
            id: 0,
            name: "",
            number: "",
            price: 0,
            total: 0
          }
        ]
      }
      return params
    },
    handleClose() {
      this.editConfig.visible = false
    },
    // 添加附件
    addAnnexClick() {},
    // 设置允许上传文件格式
    setFormatClick() {}
    setFormatClick() {},
    setTableForm() {
      this.productTableList = {
        tableData: [
          {
            id: "1",
            productName: "上海有限公司",
            other0: "ZDYBD03-1",
            other1: "12",
            other2: "5.00",
            other4: "3.00",
            other3: "2.00"
          }
        ],
        tableColumn: [
          { label: "#", prop: "id", width: 40 },
          { label: "产品名称", prop: "productName", input: true, isRequird: true },
          { label: "产品编号", prop: "other0" },
          { label: "服务开始日", prop: "other5", date: true, isRequird: true, min: 100 },
          { label: "服务到期日", prop: "other6", date: true, isRequird: true, min: 100 },
          { label: "数量", prop: "other1", input: true, isRequird: true },
          { label: "含税单价", prop: "other9", input: true },
          { label: "不含税单价", prop: "other7", input: true },
          { label: "折扣率(%)", prop: "other6", input: true },
          { label: "折扣额", prop: "other2" },
          { label: "税(销售)", prop: "other7", input: true },
          { label: "实际含税单价", prop: "other3" },
          { label: "不含税金额", prop: "other4" },
          { label: "价税合计", prop: "other3", input: true },
          { label: "描述", prop: "other8" }
        ]
      }
    }
  }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.service-contract {
.add-service-contract {
  .basic-info {
    .basic-info-title {
      background-color: #f4f8fe;
@@ -431,26 +485,6 @@
    background-color: #f5f5f5;
    height: 55px;
    line-height: 55px;
  }
}
::v-deep {
  .el-dialog__header {
    padding: 12.5px 10px;
    border-bottom: 1px solid #e5e5e5;
    .el-dialog__title {
      font-size: 15px;
      color: #323232;
      font-weight: bold;
    }
  }
  .el-dialog__body {
    padding: 0px;
  }
  .el-dialog__footer {
    padding: 0px;
    text-align: center;
    box-sizing: border-box;
    border-top: 1px solid #dadee5;
  }
}
</style>