yangfeng
2023-08-07 a2586ce70485035d77746ff9c18364f408f4c6aa
src/views/service/serviceFollowup/AddServiceFollowupDialog.vue
@@ -5,6 +5,8 @@
      :visible.sync="editConfig.visible"
      :width="dialogWidth"
      :before-close="handleClose"
      append-to-body
      custom-class="iframe-dialog"
    >
      <el-form
        ref="form"
@@ -22,23 +24,32 @@
          <div class="basic-info-view">
            <el-row>
              <el-col :span="12">
                <el-form-item label="客户名称" prop="customName">
                <el-form-item label="客户名称" prop="client_name">
                  <div class="custom-name">
                    <el-input v-model="editConfig.infomation.customName"></el-input>
                    <div class="common-select-btn"><i class="el-icon-circle-plus-outline" title="选择"></i></div>
                    <div class="common-select-btn"><i class="el-icon-edit" title="编辑"></i></div>
                    <el-autocomplete
                      v-model="editConfig.infomation.client_name"
                      :fetch-suggestions="querySearchAsync"
                      value-key="name"
                      @select="handleSelectClient"
                    ></el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
                    <div class="common-select-btn" @click="clearupClient">
                      <i class="el-icon-edit-outline" title="清除"></i>
                    </div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="回访单编号" prop="followupNumber">
                  <el-input v-model="editConfig.infomation.followupNumber"></el-input>
                <el-form-item label="回访单编号" prop="number">
                  <el-input v-model="editConfig.infomation.number"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系人姓名" prop="contactName">
                <el-form-item label="联系人姓名" prop="contactId">
                  <div class="custom-name">
                    <el-input v-model="editConfig.infomation.contactName"></el-input>
                    <el-input v-model="editConfig.infomation.contactId"></el-input>
                    <div class="common-select-btn"><i class="el-icon-circle-plus-outline" title="选择"></i></div>
                    <div class="common-select-btn"><i class="el-icon-edit" title="编辑"></i></div>
                  </div>
@@ -54,17 +65,17 @@
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="回访人" prop="visitor">
                  <el-select v-model="editConfig.infomation.visitor" size="mini">
                    <el-option v-for="item in visitorOptions" :key="item.value" :label="item.label" :value="item.value">
                <el-form-item label="回访人" prop="memberId">
                  <el-select v-model="editConfig.infomation.memberId" size="mini">
                    <el-option v-for="item in memberOptions" :key="item.id" :label="item.username" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="项目计划" prop="projectPlan">
                <el-form-item label="项目计划" prop="planId">
                  <div class="custom-name">
                    <el-input v-model="editConfig.infomation.projectPlan"></el-input>
                    <el-input v-model="editConfig.infomation.planId"></el-input>
                    <div class="common-select-btn"><i class="el-icon-circle-plus-outline" title="选择"></i></div>
                    <div class="common-select-btn"><i class="el-icon-edit" title="编辑"></i></div>
                  </div>
@@ -72,39 +83,74 @@
              </el-col>
              <el-col :span="12">
                <el-form-item label="满意度" prop="satisfaction">
                  <CommonSelectView
                    :common-value="editConfig.infomation.satisfaction"
                    :common-options="satisfactionOptions"
                  />
                  <div class="common-select">
                    <el-select
                      v-model="editConfig.infomation.satisfaction"
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                    >
                      <el-option v-for="item in satisfactionOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="及时率" prop="timelyRate">
                  <CommonSelectView
                    :common-value="editConfig.infomation.timelyRate"
                    :common-options="satisfactionOptions"
                  />
                  <div class="common-select">
                    <el-select
                      v-model="editConfig.infomation.timelyRate"
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                    >
                      <el-option v-for="item in timelyRateOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="解决率" prop="resolveRate">
                  <CommonSelectView
                    :common-value="editConfig.infomation.resolveRate"
                    :common-options="satisfactionOptions"
                  />
                <el-form-item label="解决率" prop="solveRate">
                  <div class="common-select">
                    <el-select
                      v-model="editConfig.infomation.solveRate"
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                    >
                      <el-option v-for="item in solveRateOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="原服务人员" prop="originServicePerson">
                  <el-select v-model="editConfig.infomation.originServicePerson" size="mini">
                    <el-option v-for="item in visitorOptions" :key="item.value" :label="item.label" :value="item.value">
                <el-form-item label="原服务人员" prop="oldMemberId">
                  <el-select v-model="editConfig.infomation.oldMemberId" size="mini">
                    <el-option v-for="item in oldMemberOptions" :key="item.id" :label="item.username" :value="item.id">
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="服务人员是否来过" prop="haveBeen">
                  <CommonSelectView :common-value="editConfig.infomation.haveBeen" :common-options="haveBeenOptions" />
                <el-form-item label="服务人员是否来过" prop="isVisit">
                  <div class="common-select">
                    <el-select
                      v-model="editConfig.infomation.isVisit"
                      placeholder="请选择"
                      class="common-select-sel"
                      size="mini"
                    >
                      <el-option v-for="item in isVisitOptions" :key="item.id" :label="item.name" :value="item.id">
                      </el-option>
                    </el-select>
                    <div class="common-select-btn"><i class="el-icon-setting"></i></div>
                  </div>
                </el-form-item>
              </el-col>
            </el-row>
@@ -114,12 +160,12 @@
          <div class="basic-info-view">
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="notes">
                <el-form-item label="备注" prop="remark">
                  <el-input
                    type="textarea"
                    :autosize="{ minRows: 2, maxRows: 4 }"
                    placeholder="请输入内容"
                    v-model="editConfig.infomation.notes"
                    v-model="editConfig.infomation.remark"
                  ></el-input>
                </el-form-item>
              </el-col>
@@ -131,8 +177,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>
@@ -141,18 +200,24 @@
          </div>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="small" @click="editConfig.visible = false">保并提交审批</el-button>
        <el-button type="primary" size="small" @click="editConfig.visible = false">保存</el-button>
        <el-button type="primary" size="small" @click="saveClick('form')">保存</el-button>
        <el-button size="small" @click="editConfig.visible = false">取消</el-button>
      </div>
      <!-- 选择客户 -->
      <SelectClientDialog
        v-if="editSelectClientConfig.editVisible"
        :edit-common-config="editSelectClientConfig"
        @selClient="selClient"
      />
    </el-dialog>
  </div>
</template>
<script>
import CommonSelectView from "@/components/makepager/CommonSelectView"
import { getAllData } from "@/api/client/client"
import { getAddServiceFollowup, getUpdateServiceFollowup } from "@/api/serviceManage/serviceFollowup"
import SelectClientDialog from "@/views/other/commonDialog/SelectClientDialog"
export default {
  name: "AddServiceFollowupDialog",
  props: {
@@ -162,28 +227,18 @@
        return {
          visible: false,
          title: "新建",
          infomation: {
            customName: "",
            followupNumber: "HF21",
            contactName: "",
            customServiceForm: "",
            visitor: "",
            projectPlan: "",
            satisfaction: "",
            timelyRate: "",
            resolveRate: "",
            originServicePerson: "",
            haveBeen: "",
            notes: ""
          }
          infomation: {}
        }
      }
    }
  },
  components: { CommonSelectView },
  components: { SelectClientDialog },
  computed: {
    searchCommonHeight() {
      return this.$refs.searchCommonView.offsetHeight
    },
    clientList() {
      return this.$store.state.getClientName.clientList
    }
  },
  data() {
@@ -191,22 +246,136 @@
      dialogWidth: "80%",
      editConfig: this.editCommonConfig,
      rules: {
        followupNumber: [{ required: true, message: "请输入回访单单编号", trigger: "blur" }],
        visitor: [{ required: true, message: "请选择", trigger: "change" }]
        number: [{ required: true, message: "请输入回访单单编号", trigger: "blur" }],
        memberId: [{ required: true, message: "请选择", trigger: "change" }]
      },
      satisfactionOptions: [], // 满意度 及时率 解决率
      haveBeenOptions: [], // 服务人员是否来过
      visitorOptions: [
        // 回访人
        { value: "1", label: "系统管理员" },
        { value: "2", label: "销售总监" }
      ]
      satisfactionOptions: [], // 满意度
      timelyRateOptions: [], // 及时率
      solveRateOptions: [], // 解决率
      oldMemberOptions: [], // 原服务人员
      isVisitOptions: [], // 服务人员是否来过
      memberOptions: [],
      editSelectClientConfig: {
        editVisible: false,
        title: "",
        infomation: {}
      }
    }
  },
  created() {},
  created() {
    this.$store.dispatch("geClient")
    this.getCommonData()
  },
  methods: {
    getCommonData() {
      getAllData()
        .then((res) => {
          this.memberOptions = res.data.member
          this.satisfactionOptions = res.data.satisfaction // 满意度
          this.timelyRateOptions = res.data.timely_rate // 及时率
          this.solveRateOptions = res.data.solve_rate // 解决率
          this.oldMemberOptions = res.data.member // 原服务人员
          this.isVisitOptions = res.data.isVisit // 服务人员是否来过
        })
        .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 === "新建") {
            getAddServiceFollowup(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 {
            getUpdateServiceFollowup(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,
        contactId: data.contactId || 0,
        file: data.file || "",
        isVisit: data.isVisit || 0,
        memberId: data.memberId || 0,
        number: data.number || "",
        oldMemberId: data.oldMemberId || 0,
        planId: data.planId || 0,
        remark: data.remark || "",
        satisfaction: data.satisfaction || 0,
        serviceId: data.serviceId || 0,
        solveRate: data.solveRate || 0,
        timelyRate: data.timelyRate || 0
      }
      return params
    },
    handleClose() {
      this.editConfig.visible = false
    },
    // 选择客户相关方法
    querySearchAsync(queryString, cb) {
      var restaurants = this.clientList
      var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
      cb(results)
    },
    createStateFilter(queryString) {
      return (state) => {
        return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
      }
    },
    handleSelectClient(item) {
      this.editConfig.infomation.client_id = item.id
    },
    selClientClick() {
      this.editSelectClientConfig.editVisible = true
    },
    selClient(row) {
      console.log(row)
      this.editConfig.infomation.client_name = row.name
      this.editConfig.infomation.client_id = row.id
    },
    // 清除已选择用户
    clearupClient() {
      this.editConfig.infomation.client_name = ""
      this.editConfig.infomation.client_id = 0
    },
    // 添加附件
    addAnnexClick() {},
@@ -218,71 +387,54 @@
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.service-followup {
  .basic-info {
    .basic-info-title {
      background-color: #f4f8fe;
      padding-left: 10px;
      font-size: 15px;
      font-weight: bold;
      color: #666;
      height: 42px;
      line-height: 42px;
    }
    .basic-info-view {
      margin-top: 10px;
      padding-right: 40px;
      .custom-name {
::v-deep {
  .iframe-dialog .el-dialog__body {
    .basic-info {
      .basic-info-title {
        background-color: #f4f8fe;
        padding-left: 10px;
        font-size: 15px;
        font-weight: bold;
        color: #666;
        height: 42px;
        line-height: 42px;
      }
      .basic-info-view {
        margin-top: 10px;
        padding-right: 40px;
        .custom-name,
        .common-select {
          display: flex;
          .common-select-sel {
            width: 270px;
          }
          .common-select-btn {
            margin-left: 5px;
            font-size: 16px;
            cursor: pointer;
          }
        }
      }
      .annex-view {
        display: flex;
        .common-select-btn {
          margin-left: 5px;
          font-size: 18px;
        color: #6166d3;
        .setFormat {
          margin-left: 10px;
        }
      }
    }
    .address-view {
      margin-top: 10px;
      padding-right: 40px;
    }
    .annex-view {
    .unflod-collapse {
      display: flex;
      height: 30px;
      justify-content: center;
      align-items: center;
      color: #6166d3;
      .setFormat {
        margin-left: 10px;
      }
    }
  }
  .unflod-collapse {
    display: flex;
    height: 30px;
    justify-content: center;
    align-items: center;
    color: #6166d3;
  }
  .dialog-footer {
    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;
    .dialog-footer {
      background-color: #f5f5f5;
      height: 55px;
      line-height: 55px;
    }
  }
  .el-dialog__body {
    padding: 0px;
  }
  .el-dialog__footer {
    padding: 0px;
    text-align: center;
    box-sizing: border-box;
    border-top: 1px solid #dadee5;
  }
}
</style>