Pārlūkot izejas kodu

新增收货人信息,新建跟进

wsx 11 mēneši atpakaļ
vecāks
revīzija
f65607a0b6

+ 320 - 0
src/views/saleManage/followList/components/addFollowDialog.vue

@@ -0,0 +1,320 @@
+<template>
+  <div class="container">
+    <!-- 单据弹窗 -->
+    <el-dialog
+      :title="title"
+      :before-close="handleClose"
+      custom-class="ele-dialog-form long-dialog-form"
+      :visible.sync="dialogVisible"
+      :close-on-click-modal="false"
+      :append-to-body="true"
+      width="60%"
+    >
+      <el-form
+        label-width="100px"
+        ref="form"
+        :model="form"
+        :rules="rules"
+        style="margin-top: 30px; padding-right: 20px"
+      >
+        <el-form-item label="客户名称" prop="partaName">
+          <el-input
+            clearable
+            v-model="form.partaName"
+            @click.native="handParent"
+            placeholder="请选择"
+            readonly
+          />
+        </el-form-item>
+
+        <el-form-item label="客户联系人" prop="linkId">
+          <el-select
+            v-model="form.linkId"
+            multiple
+            placeholder="请选择"
+            style="width: 300px"
+            @change="onchangeLink"
+          >
+            <el-option
+              v-for="item in linkNameOptions"
+              :key="item.id"
+              :label="item.linkName"
+              :value="item.id"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="商机名称" prop="opportunityId">
+          <el-select
+            v-model="form.opportunityId"
+            placeholder="请选择"
+            style="width: 300px"
+          >
+            <el-option
+              v-for="item in opportunityList"
+              :key="item.id"
+              :label="item.name"
+              :value="item.id"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+
+        <el-form-item label="跟进时间" prop="followupTime">
+          <el-date-picker
+            v-model="form.followupTime"
+            value-format="yyyy-MM-dd HH:mm:ss"
+            placeholder="结束时间"
+            type="datetime"
+            style="width: 200px"
+            class="filter-item"
+          ></el-date-picker>
+        </el-form-item>
+        <el-form-item label="跟进阶段" prop="stageCode">
+          <DictSelection dictName="商机阶段" clearable v-model="form.stageCode">
+          </DictSelection>
+        </el-form-item>
+        <el-form-item label="跟进内容" prop="content">
+          <el-input
+            placeholder="请输入"
+            type="textarea"
+            v-model="form.content"
+            maxlength="500"
+          ></el-input>
+        </el-form-item>
+        <el-form-item label="达成共识" prop="agreement">
+          <el-input
+            placeholder="请输入"
+            type="textarea"
+            v-model="form.agreement"
+            maxlength="500"
+          ></el-input>
+        </el-form-item>
+
+        <el-form-item label="下一步计划" prop="nextPlan">
+          <el-input
+            placeholder="请输入"
+            v-model="form.nextPlan"
+            type="textarea"
+            maxlength="300"
+          ></el-input>
+        </el-form-item>
+        <el-form-item prop="files" label="附件">
+          <fileMain v-model="form.files"></fileMain>
+        </el-form-item>
+      </el-form>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button size="small" @click="handleClose">关 闭</el-button>
+        <el-button size="small" @click="sumbit" type="primary">确 认</el-button>
+      </div>
+    </el-dialog>
+
+    <parentList ref="parentRef" @changeParent="changeParent"></parentList>
+  </div>
+</template>
+<script>
+  import dictMixins from '@/mixins/dictMixins';
+  import { copyObj } from '@/utils/util';
+  import parentList from '@/views/saleManage/contact/components/parentList.vue';
+
+  import { contactDetail } from '@/api/saleManage/contact';
+
+  import { getTableList } from '@/api/saleManage/businessOpportunity';
+
+  import { addInformation } from '@/api/saleManage/businessFollow';
+
+  import { deepClone } from '@/utils/index';
+
+  // import fileMain from '@/components/addDoc/index';
+
+  export default {
+    mixins: [dictMixins],
+    components: {
+      // fileMain
+      parentList
+    },
+    data() {
+      let formDef = {
+        agreement: '',
+        contactId: '',
+        content: '',
+        followupTime: '',
+        linkId: '',
+        linkName: '',
+        nextPlan: '',
+        opportunityId: '',
+        stageCode: '',
+        files: [],
+        stageName: ''
+      };
+
+      return {
+        dialogVisible: false,
+        currentDetail: {}, //选择的客户信息
+        linkNameOptions: [],
+        title: '',
+        row: {},
+        activeName: 'base',
+        formDef,
+        form: copyObj(formDef),
+        rules: {
+          content: [
+            { required: true, message: '请输入跟进内容', trigger: 'blur' }
+          ],
+          followupTime: [
+            { required: true, message: '请选择跟进时间', trigger: 'change' }
+          ],
+          stageCode: [
+            { required: true, message: '请选择跟进阶段', trigger: 'change' }
+          ],
+
+          linkName: [
+            {
+              required: true,
+              message: '请选择客户联系人名称',
+              trigger: 'change'
+            }
+          ]
+        },
+
+        // 提交状态
+        loading: false,
+        // 是否是修改
+        isUpdate: false,
+        index: '',
+        type: ''
+      };
+    },
+    created() {},
+    methods: {
+      //更改弹框状态
+      async open(type, row, linkNameOptions, index) {
+        this.linkNameOptions = linkNameOptions;
+        this.title = type === 'add' ? '新增' : '修改';
+        this.index = index;
+        this.type = type;
+        this.row = copyObj(row);
+        this.dialogVisible = true;
+        if (type != 'add') {
+          this.form = this.row;
+          if (row.linkId) {
+            this.$set(this.form, 'linkId', row.linkId.split(','));
+          }
+        }
+      },
+
+      //表单验证
+      getValidate() {
+        return new Promise((resolve, reject) => {
+          this.$refs.form.validate((valid) => {
+            if (!valid) {
+              reject(false);
+            } else {
+              resolve(true);
+            }
+          });
+        });
+      },
+
+      //选择下拉框
+      onchangeLink(selectedOptions) {
+        const selectedLabels = selectedOptions
+          .map((optionId) => {
+            const option = this.linkNameOptions.find(
+              (opt) => opt.id === optionId
+            );
+            return option ? option.linkName : '';
+          })
+          .join(',');
+
+        this.form.linkName = selectedLabels;
+      },
+
+      //保存
+      async sumbit() {
+        try {
+          await this.getValidate();
+          this.form.stageName = this.getDictValue(
+            '商机阶段',
+            this.form.stageCode
+          );
+          let params = deepClone(this.form);
+
+          params = Object.assign({}, params, {
+            linkId: params?.linkId?.join(',') || ''
+          });
+
+          addInformation(params)
+            .then((res) => {
+              this.loading = false;
+              this.$message.success('新增成功');
+              this.cancel();
+              this.$emit('done');
+            })
+            .catch((e) => {
+              //this.loading = false;
+            });
+
+          // this.$emit('done', {
+          //   data: JSON.parse(JSON.stringify(this.form)),
+          //   type: this.type,
+          //   index: this.index
+          // });
+
+          this.cancel();
+        } catch (error) {
+          console.log(error);
+          // 表单验证未通过,不执行保存操作
+        }
+      },
+      cancel() {
+        this.$nextTick(() => {
+          // 关闭后,销毁所有的表单数据
+          this.$refs['form'] && this.$refs['form'].resetFields();
+          (this.form = copyObj(this.formDef)), (this.dialogVisible = false);
+        });
+      },
+      handleClose() {
+        this.cancel();
+      },
+
+      handParent() {
+        // if (this.form.contractId) {
+        //   return this.$message.error('选择了合同不能更改客户名称');
+        // }
+        let item = {
+          id: undefined
+        };
+        this.$refs.parentRef.open(item);
+      },
+
+      //选择客户回调
+      async changeParent(obj, isCustomerMark) {
+        const { base, other, linkList } = await contactDetail(obj.id);
+
+        let res = await getTableList({
+          pageNum: 1,
+          size: 10,
+          contactId: obj.id
+        });
+
+        this.opportunityList = res.list;
+
+        this.linkNameOptions = linkList;
+
+        this.form = Object.assign({}, this.form, {
+          contactId: base?.id,
+          partaName: base?.name
+        });
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .container {
+    padding: 10px 0;
+  }
+</style>

+ 82 - 5
src/views/saleManage/followList/components/list.vue

@@ -23,9 +23,56 @@
           {{ row.followupCount }}
         </el-link>
       </template>
+
+      <template v-slot:toolbar v-if="queryType === 0">
+        <el-button
+          size="small"
+          type="primary"
+          icon="el-icon-plus"
+          class="ele-btn-icon"
+          @click="openEdit('add', {})"
+        >
+          新建
+        </el-button>
+        <el-button
+          size="small"
+          type="danger"
+          el-icon-delete
+          class="ele-btn-icon"
+          @click="allDelBtn"
+          :disabled="selection?.length === 0"
+        >
+          批量删除
+        </el-button>
+      </template>
+
+      <template v-slot:action="{ row }">
+        <el-link
+          type="primary"
+          :underline="false"
+          icon="el-icon-edit"
+          @click="openEdit('编辑', row)"
+        >
+          修改
+        </el-link>
+
+        <el-popconfirm
+          class="ele-action"
+          title="确定要删除此信息吗?"
+          @confirm="remove(row)"
+        >
+          <template v-slot:reference>
+            <el-link type="danger" :underline="false" icon="el-icon-delete">
+              删除
+            </el-link>
+          </template>
+        </el-popconfirm>
+      </template>
     </ele-pro-table>
 
     <viewDialog ref="viewDialogRef"></viewDialog>
+
+    <AddFollowDialog ref="addFollowDialogRef" @done="done"></AddFollowDialog>
   </div>
 </template>
 
@@ -36,11 +83,14 @@
   import searchTable from './searchTable.vue';
   import { groupByContact } from '@/api/saleManage/contact.js';
 
+  import AddFollowDialog from './addFollowDialog.vue';
+
   export default {
     mixins: [dictMixins, tabMixins],
     components: {
       searchTable,
-      viewDialog
+      viewDialog,
+      AddFollowDialog
     },
     props: {
       queryType: {
@@ -53,14 +103,15 @@
         // 加载状态
         loading: false,
         cacheKeyUrl: 'eos-be72e790-followList-myList',
-        columnsVersion: 1
+        columnsVersion: 1,
+        selection: []
       };
     },
     computed: {
       columns() {
         // 当columnsVersion变化时会重新计算,用作更新列配置
         const version = this.columnsVersion;
-        return [
+        let arr = [
           {
             width: 60,
             label: '序号',
@@ -111,8 +162,24 @@
             label: '最近一次跟进时间',
             align: 'center',
             showOverflowTooltip: true
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 180,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            showOverflowTooltip: true,
+            fixed: 'right'
           }
         ];
+
+        if (this.queryType === 1) {
+          arr.pop();
+        }
+
+        return arr;
       }
     },
     created() {},
@@ -125,8 +192,8 @@
             deptIds: row.deptIds,
             beginTime: row.beginTime,
             endTime: row.endTime,
-            deptId:row.deptId,
-            userId:row.userId
+            deptId: row.deptId,
+            userId: row.userId
           });
         });
       },
@@ -144,6 +211,16 @@
       /* 刷新表格 */
       reload(where = {}) {
         this.$refs.table.reload({ page: 1, where });
+      },
+      openEdit(type, row, index) {
+        this.$refs.addFollowDialogRef.open(type, row, index);
+        this.$refs.addFollowDialogRef.$refs.form &&
+          this.$refs.addFollowDialogRef.$refs.form.clearValidate();
+      },
+      allDelBtn() {},
+      remove() {},
+      done({ data }) {
+        console.log(data);
       }
     }
   };

+ 19 - 3
src/views/saleManage/saleOrder/components/addDialog.vue

@@ -390,6 +390,14 @@
           </el-form-item>
         </el-col>
       </el-row>
+
+      <el-row style="margin-top: 20px">
+        <el-col :span="12">
+          <el-form-item label="收货人信息" prop="receivePerson">
+            <el-input  clearable v-model="form.receivePerson" />
+          </el-form-item>
+        </el-col>
+      </el-row>
     </el-form>
 
     <div slot="footer" class="footer">
@@ -541,7 +549,8 @@
         partbName: '',
         partbTel: '',
         needProduce: 1,
-        planNumUnit: '立方'
+        planNumUnit: '立方',
+        receivePerson: ''
       };
 
       return {
@@ -896,15 +905,20 @@
       },
       //选择客户回调
       async changeParent(obj, isCustomerMark) {
-        const { base, other } = await contactDetail(obj.id);
+        const { base, other, linkList } = await contactDetail(obj.id);
         const userInfo = base?.salesmanId
           ? await getUserDetail(base?.salesmanId)
           : {};
 
         this.customerMark = base?.serialNo;
+        // 新增时带出默认收货人
+        const defaultReceived = linkList.find((item) => item.isDefault === 1);
+        this.form.receivePerson = defaultReceived?.linkName;
+
         if (isCustomerMark) {
           return;
         }
+
         this.form = Object.assign({}, this.form, {
           partaId: base?.id,
           partaName: base?.name,
@@ -915,7 +929,8 @@
           partaTel: '',
           partaUnifiedSocialCreditCode: base?.unifiedSocialCreditCode,
           customerMark: base?.serialNo,
-          receiveAddress: other?.addressName + other?.address
+          receiveAddress: other?.addressName + other?.address,
+          receivePerson: defaultReceived?.linkName
         });
         this.changePersonel(userInfo?.id ? userInfo : '');
 
@@ -1120,6 +1135,7 @@
       },
 
       getValidate() {
+        console.log(this.form);
         let arr = [
           new Promise((resolve, reject) => {
             this.$refs.form.validate((valid) => {