| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <template>
- <el-form ref="form" :model="form" :rules="rules">
- <ele-pro-table
- ref="table"
- :needPage="false"
- :columns="columns"
- :datasource="form.datasource"
- cache-key="systemRoleTable17"
- class="time-form"
- :toolkit="[]"
- >
- <!-- 表头工具栏 -->
- <template v-slot:toolbar>
- <el-button
- size="small"
- type="primary"
- icon="el-icon-plus"
- class="ele-btn-icon"
- @click="handlAdd"
- >
- 新增
- </el-button>
- <el-button
- size="small"
- type="primary"
- class="ele-btn-icon"
- @click="save"
- v-if="isDrawer"
- >
- 保存
- </el-button>
- </template>
- <template v-slot:linkId="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'datasource.' + scope.$index + '.linkId'"
- :rules="{
- required: true,
- message: '请选择',
- trigger: 'change'
- }"
- >
- <el-select
- v-model="scope.row.linkId"
- placeholder="请选择"
- @change="changePersonel(scope.row, $event)"
- >
- <el-option
- v-for="item in linkNameOptions"
- :key="item.id"
- :label="item.linkName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </template>
- <template v-slot:linkPost="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'datasource.' + scope.$index + '.linkPost'"
- >
- <el-input
- v-model="scope.row.linkPost"
- disabled
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:linkMobilePhone="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'datasource.' + scope.$index + '.linkMobilePhone'"
- >
- <el-input
- v-model="scope.row.linkMobilePhone"
- disabled
- placeholder="请输入"
- ></el-input>
- </el-form-item>
- </template>
- <template v-slot:goal="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'datasource.' + scope.$index + '.goal'"
- :rules="{
- required: true,
- message: '请输入',
- trigger: 'change'
- }"
- >
- <el-input v-model="scope.row.goal" placeholder="请输入"></el-input>
- </el-form-item>
- </template>
- <template v-slot:influenceCode="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'datasource.' + scope.$index + '.influenceCode'"
- :rules="{
- required: true,
- message: '请选择',
- trigger: 'change'
- }"
- >
- <DictSelection
- dictName="影响力"
- clearable
- v-model="scope.row.influenceCode"
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:attitudeCode="scope">
- <el-form-item
- style="margin-bottom: 20px"
- :prop="'datasource.' + scope.$index + '.attitudeCode'"
- :rules="{
- required: true,
- message: '请选择',
- trigger: 'change'
- }"
- >
- <DictSelection
- dictName="态度"
- clearable
- v-model="scope.row.attitudeCode"
- >
- </DictSelection>
- </el-form-item>
- </template>
- <template v-slot:headerLinkId="{ column }">
- <span class="is-required">{{ column.label }}</span>
- </template>
- <template v-slot:headerGoal="{ column }">
- <span class="is-required">{{ column.label }}</span>
- </template>
- <template v-slot:headerInfluenceCode="{ column }">
- <span class="is-required">{{ column.label }}</span>
- </template>
- <template v-slot:headerAttitudeCode="{ column }">
- <span class="is-required">{{ column.label }}</span>
- </template>
- <!-- 操作列 -->
- <template v-slot:action="{ row }">
- <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>
- </el-form>
- </template>
- <script>
- import { getcontactlink } from '@/api/saleManage/businessFollow';
- import dictMixins from '@/mixins/dictMixins';
- export default {
- props: {
- delDetailIds: Array,
- isDrawer: {
- type: Boolean,
- default: false
- },
- contactId: {
- type: String,
- default: ''
- }
- },
- mixins: [dictMixins],
- data() {
- const defaultForm = {
- key: null,
- linkId: '',
- linkPost: '',
- linkMobilePhone: '',
- goal: '',
- influenceCode: '',
- influenceName: '',
- attitudeCode: '',
- attitudeName: ''
- };
- return {
- newContactId: '',
- linkNameOptions: [],
- defaultForm,
- form: {
- datasource: []
- },
- rules: {},
- columns: [
- {
- width: 45,
- type: 'index',
- columnKey: 'index',
- align: 'center',
- fixed: 'left'
- },
- {
- prop: 'linkId',
- label: '姓名',
- slot: 'linkId',
- headerSlot: 'headerLinkId',
- align: 'center'
- },
- {
- prop: 'linkPost',
- label: '职位',
- slot: 'linkPost',
- align: 'center'
- },
- {
- prop: 'linkMobilePhone',
- label: '联系方式',
- slot: 'linkMobilePhone',
- align: 'center'
- },
- {
- prop: 'goal',
- label: '项目目标/期望',
- slot: 'goal',
- headerSlot: 'headerGoal',
- align: 'center'
- },
- {
- prop: 'influenceCode',
- label: '影响力',
- slot: 'influenceCode',
- headerSlot: 'headerInfluenceCode',
- align: 'center'
- },
- {
- prop: 'attitudeCode',
- label: '态度',
- slot: 'attitudeCode',
- headerSlot: 'headerAttitudeCode',
- align: 'center'
- },
- {
- width: 100,
- columnKey: 'action',
- label: '操作',
- align: 'center',
- resizable: false,
- slot: 'action',
- showOverflowTooltip: true
- }
- ]
- };
- },
- computed: {
- canHandl() {
- return this.form.datasource.length;
- }
- },
- watch: {
-
- },
- methods: {
- //初始数据
- async getContactIdInfo(contactId) {
- const data = await getcontactlink({ contactId});
- if (data && data?.length) {
- this.linkNameOptions = data;
- }
- },
- //修改回显
- putTableValue(data, contactId) {
- if (contactId) {
- this.getContactIdInfo(contactId);
- }
- if (data && data?.length) {
- this.form.datasource = data;
- }
- },
- // 返回列表数据
- getTableValue() {
- let _datasource = this.form.datasource || [];
- if (_datasource.length === 0) return;
- _datasource.forEach((v, index) => {
- if (_datasource[index].influenceCode) {
- _datasource[index].influenceName = this.getDictValue(
- '影响力',
- _datasource[index].influenceCode
- );
- }
- if (_datasource[index].attitudeCode) {
- _datasource[index].attitudeName = this.getDictValue(
- '态度',
- _datasource[index].attitudeCode
- );
- }
- });
- return _datasource;
- },
- //选择关键人
- changePersonel(row, val) {
-
- let selectVal = this.linkNameOptions.find((v) => v.id === val);
- row.linkPost = selectVal.post;
- row.linkMobilePhone = selectVal.mobilePhone|| selectVal.phone;
- },
- remove(row) {
- let index = this.form.datasource.findIndex((n) => n.key == row.key);
- if (index !== -1) {
- this.form.datasource.splice(index, 1);
- this.setSort();
- if (row.id) {
- this.delDetailIds.push(row.id);
- }
- }
- },
- // 清空表格
- restTable() {
- this.form.datasource = [];
- },
- // 重新排序
- setSort() {
- this.form.datasource.forEach((n, index) => {
- n.key = index + 1;
- });
- },
- // 添加
- handlAdd() {
- this.$emit('getContactId', (id) => {
- if (!id) {
- return this.$message.error('请先选择客户');
- }
- this.getContactIdInfo(id);
- let item = JSON.parse(JSON.stringify(this.defaultForm));
- item.key = this.form.datasource.length + 1;
- this.form.datasource.push(item);
- });
- },
- save() {
- this.$emit('save');
- },
- validateForm(callback) {
- //开始表单校验
- this.$refs.form.validate((valid) => {
- callback(valid);
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .time-form .el-form-item {
- margin-bottom: 0 !important;
- }
- </style>
|