|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
|
|
<!-- 参数配置弹窗 -->
|
|
<!-- 参数配置弹窗 -->
|
|
|
<FormDialog
|
|
<FormDialog
|
|
|
|
|
+ width="680px"
|
|
|
class="parameter_setting_form_dialog"
|
|
class="parameter_setting_form_dialog"
|
|
|
v-if="formVisible"
|
|
v-if="formVisible"
|
|
|
:defaultFormData="{}"
|
|
:defaultFormData="{}"
|
|
@@ -22,13 +23,22 @@
|
|
|
>
|
|
>
|
|
|
<template #form_pre>
|
|
<template #form_pre>
|
|
|
<div class="dictionary_box">
|
|
<div class="dictionary_box">
|
|
|
- <!-- v-model:tableRef="dictionaryTableDom" -->
|
|
|
|
|
<Table
|
|
<Table
|
|
|
|
|
+ v-model:tableRef="configTableDom"
|
|
|
:tableColumns="finalTableColumns"
|
|
:tableColumns="finalTableColumns"
|
|
|
:tableData="tableData"
|
|
:tableData="tableData"
|
|
|
:hidePagination="true">
|
|
:hidePagination="true">
|
|
|
<template #moveable="{row,currentIndex}">
|
|
<template #moveable="{row,currentIndex}">
|
|
|
- <TableRowDragUpDown :currentIndex="currentIndex" :tableRow="row" :defaultTableData="tableData" @moveChange="HandleRowMove"/>
|
|
|
|
|
|
|
+
|
|
|
|
|
+ <TableRowDragUpDown
|
|
|
|
|
+ :startIndex="middleColumnItm?.label == '跟进状态' ? 1 : 0"
|
|
|
|
|
+ :endIndex="middleColumnItm?.label == '跟进状态' ? tableData.length - 4 : tableData.length - 1"
|
|
|
|
|
+ v-if="!(middleColumnItm?.label == '跟进状态'
|
|
|
|
|
+ &&([1,tableData.length, tableData.length-1, tableData.length-2].includes(currentIndex) ))"
|
|
|
|
|
+
|
|
|
|
|
+ :currentIndex="currentIndex"
|
|
|
|
|
+ :tableRow="row" :defaultTableData="tableData"
|
|
|
|
|
+ @moveChange="HandleRowMove"/>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template #num="{row,currentIndex}">
|
|
<template #num="{row,currentIndex}">
|
|
@@ -36,56 +46,75 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:[middleColumnItm?.name]="{row}">
|
|
<template v-slot:[middleColumnItm?.name]="{row}">
|
|
|
- {{ row?.[middleColumnItm?.name] }}
|
|
|
|
|
- </template>
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
- <template #dictName="{row}">
|
|
|
|
|
- <el-input v-model="row.dictName" v-if="row.tmpId" placeholder="请输入选项内容"></el-input>
|
|
|
|
|
- <span v-else>{{ row.dictName }}</span>
|
|
|
|
|
|
|
+ <!-- 地区管理的下拉为省份 -->
|
|
|
|
|
+ <template v-if="middleColumnItm?.label == '省份'">
|
|
|
|
|
+ <el-select v-model="row[middleColumnItm.name]" v-if="row.tmpId">
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ label="输入框"
|
|
|
|
|
+ :value="1"
|
|
|
|
|
+ />
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ label="单选"
|
|
|
|
|
+ :value="2"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ <span v-else>{{ row?.[middleColumnItm?.name] }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-else>
|
|
|
|
|
+ <el-input v-model="row[middleColumnItm.name]" v-if="row.tmpId" placeholder="请输入内容" />
|
|
|
|
|
+ <span v-else>{{ row?.[middleColumnItm?.name] }}</span>
|
|
|
|
|
+ </template>
|
|
|
</template>
|
|
</template>
|
|
|
-
|
|
|
|
|
- <template #dictType="{row}">
|
|
|
|
|
- <el-select v-model="row.dictType" v-if="row.tmpId" @change="(val)=>HandleRowTypeChange(row,val)">
|
|
|
|
|
- <el-option
|
|
|
|
|
- label="输入框"
|
|
|
|
|
- :value="1"
|
|
|
|
|
- />
|
|
|
|
|
- <el-option
|
|
|
|
|
- label="单选"
|
|
|
|
|
- :value="2"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- <span v-else>{{ DictTypeNumToName(row.dictType) }}</span>
|
|
|
|
|
- </template>
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
- <template #operation="{row}">
|
|
|
|
|
|
|
+ <template #operation="{row,currentIndex}">
|
|
|
<div class="table_row_option">
|
|
<div class="table_row_option">
|
|
|
- <span :class="row.defaultStatus ? 'el_button_editor' : 'editor_disable'" @click="row.defaultStatus ? HandleDictionaryEditOrSave(row) : ''">{{row.tmpId ? '保存' : '编辑'}}</span>
|
|
|
|
|
- <span v-if="row.tmpId" class="el_button_editor" @click="HandleDictionaryCancel(row)">取消</span>
|
|
|
|
|
- <span v-else :class="row.defaultStatus ? 'el_button_delete' : 'editor_disable'" @click="row.defaultStatus ? HandleDictionaryDelete(row) : ''">删除</span>
|
|
|
|
|
|
|
+ <!-- row.defaultStatus ? -->
|
|
|
|
|
+ <span :class="'el_button_editor'" @click="HandleConfigEditOrSave(row)">{{row.tmpId ? '保存' : '编辑'}}</span>
|
|
|
|
|
+ <span v-if="row.tmpId" class="el_button_editor" @click="HandleConfigCancel(row)">取消</span>
|
|
|
|
|
+ <!-- row.defaultStatus -->
|
|
|
|
|
+ <!-- editor_disable -->
|
|
|
|
|
+ <span v-else :class="middleColumnItm?.label == '跟进状态'&& [1,tableData.length, tableData.length-1, tableData.length-2].includes(currentIndex) ? 'editor_disable' : 'el_button_delete'"
|
|
|
|
|
+ @click="middleColumnItm?.label == '跟进状态'&& [1,tableData.length, tableData.length-1, tableData.length-2].includes(currentIndex) ? '' : HandleConfigDelete(row)"
|
|
|
|
|
+ >删除</span>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</Table>
|
|
</Table>
|
|
|
- <div class="add_option" @click="HandleAddDictionary">
|
|
|
|
|
|
|
+ <div class="add_option" @click="HandleAddConfig">
|
|
|
<el-icon><CloseBold /></el-icon>
|
|
<el-icon><CloseBold /></el-icon>
|
|
|
<span>增加选项配置</span>
|
|
<span>增加选项配置</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</FormDialog>
|
|
</FormDialog>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 删除弹窗 -->
|
|
|
|
|
+ <Dialog
|
|
|
|
|
+ v-if="dialogVisible"
|
|
|
|
|
+ :submitLoading="dialogSubmitLoading"
|
|
|
|
|
+ :visible="dialogVisible"
|
|
|
|
|
+ @confirm="HandleDialogConfirm"
|
|
|
|
|
+ @close="HandleDialogClose">
|
|
|
|
|
+ 是否确认删除?
|
|
|
|
|
+ </Dialog>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref,watch } from 'vue';
|
|
|
|
|
|
|
+import { ref,watch, nextTick } from 'vue';
|
|
|
|
|
+import {ElMessage} from 'element-plus'
|
|
|
import FormDialog from '@/baseComponents/FormDialog.vue';
|
|
import FormDialog from '@/baseComponents/FormDialog.vue';
|
|
|
|
|
+import Dialog from '@/baseComponents/Dialog.vue';
|
|
|
import Table from '@/baseComponents/Table.vue';
|
|
import Table from '@/baseComponents/Table.vue';
|
|
|
import TableRowDragUpDown from '@/baseComponents/TableRowDragUpDown.vue';
|
|
import TableRowDragUpDown from '@/baseComponents/TableRowDragUpDown.vue';
|
|
|
|
|
|
|
|
import {tableColumns} from './table'
|
|
import {tableColumns} from './table'
|
|
|
|
|
|
|
|
|
|
+interface MiddleColumnItm {
|
|
|
|
|
+ name:string,
|
|
|
|
|
+ label:string
|
|
|
|
|
+}
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
cardItems:{
|
|
cardItems:{
|
|
|
type:Array,
|
|
type:Array,
|
|
@@ -96,7 +125,7 @@ const props = defineProps({
|
|
|
default:''
|
|
default:''
|
|
|
},
|
|
},
|
|
|
middleColumnItm:{
|
|
middleColumnItm:{
|
|
|
- type:Object
|
|
|
|
|
|
|
+ type:Object as ()=>MiddleColumnItm
|
|
|
},
|
|
},
|
|
|
defaultTableData:{
|
|
defaultTableData:{
|
|
|
type:Array,
|
|
type:Array,
|
|
@@ -104,18 +133,149 @@ const props = defineProps({
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const emit = defineEmits([''])
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 1. 参数配置: 表单弹窗信息
|
|
|
|
|
+ */
|
|
|
const formVisible = defineModel('formVisible')
|
|
const formVisible = defineModel('formVisible')
|
|
|
const formSubmitLoading = ref(false)
|
|
const formSubmitLoading = ref(false)
|
|
|
const finalTableColumns = ref([...tableColumns.value]) //最终渲染的表头
|
|
const finalTableColumns = ref([...tableColumns.value]) //最终渲染的表头
|
|
|
-const tableData = ref([]) //表数据
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+const tableData = ref<any[]>([]) //表数据
|
|
|
|
|
+const configTableDom = ref()
|
|
|
|
|
|
|
|
// 处理表行的上下移动
|
|
// 处理表行的上下移动
|
|
|
const HandleRowMove = (val)=>{
|
|
const HandleRowMove = (val)=>{
|
|
|
tableData.value = val
|
|
tableData.value = val
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 处理参数配置的增删改查
|
|
|
|
|
+// 配置项添加
|
|
|
|
|
+const HandleAddConfig = async ()=>{
|
|
|
|
|
+ if(props.middleColumnItm?.label === '跟进状态'){
|
|
|
|
|
+ tableData.value.splice(tableData.value.length - 3,0,{
|
|
|
|
|
+ // 临时id _ 待完善
|
|
|
|
|
+ id:`tmp_${new Date().getTime()}_${tableData.value.length + 1}`,
|
|
|
|
|
+ tmpId:(Number(tableData.value[tableData.value.length - 1]?.tmpId) || 0) + 1, //新增时候的临时id
|
|
|
|
|
+ [props.middleColumnItm?.name]:'',
|
|
|
|
|
+ defaultStatus:1, // defaultStatus: 0默认项 1非默认项 ,后续可能会用
|
|
|
|
|
+ })
|
|
|
|
|
+ }else{
|
|
|
|
|
+ tableData.value.push({
|
|
|
|
|
+ // 临时id _ 待完善
|
|
|
|
|
+ id:`tmp_${new Date().getTime()}_${tableData.value.length + 1}`,
|
|
|
|
|
+ tmpId:(Number(tableData.value[tableData.value.length - 1]?.tmpId) || 0) + 1, //新增时候的临时id
|
|
|
|
|
+ [props.middleColumnItm?.name]:'',
|
|
|
|
|
+ defaultStatus:1, // defaultStatus: 0默认项 1非默认项 ,后续可能会用
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ await nextTick()
|
|
|
|
|
+ // 新增元素后滚动到表格最底层
|
|
|
|
|
+ configTableDom.value.setScrollTop(configTableDom.value.layout.table.refs.bodyWrapper.firstElementChild.firstElementChild.scrollHeight)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// dictContent
|
|
|
|
|
+// dictName —— 后续待替换 待完善
|
|
|
|
|
+// 配置项保存 /编辑
|
|
|
|
|
+const HandleConfigEditOrSave = async (row)=>{
|
|
|
|
|
+ // 初次新增确认 或者 准备变成编辑状态
|
|
|
|
|
+ if(!row.editFlag){
|
|
|
|
|
+ if(row.tmpId){
|
|
|
|
|
+ // 初次新增确认
|
|
|
|
|
+ // 调用新增接口
|
|
|
|
|
+ // 接口调用
|
|
|
|
|
+ if(!(row?.[props?.middleColumnItm?.name]) ){
|
|
|
|
|
+ ElMessage.warning('请填写内容')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ dictName: row.dictName,
|
|
|
|
|
+ dictContent: row.dictContent,
|
|
|
|
|
+ }
|
|
|
|
|
+ let res = await addDictionaryApi(params)
|
|
|
|
|
+
|
|
|
|
|
+ if(res.code == 200){
|
|
|
|
|
+ ElMessage.success(res.msg)
|
|
|
|
|
+ row.id = res?.data?.id
|
|
|
|
|
+ row.dictContent = res?.data?.dictContent
|
|
|
|
|
+ row.tmpId = ''
|
|
|
|
|
+ row.editFlag = ''
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 准备变成编辑状态
|
|
|
|
|
+ row.editFlag = 'edit'
|
|
|
|
|
+ row.tmpId = row.id
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ // 准备保存修改
|
|
|
|
|
+ // 调用修改接口
|
|
|
|
|
+ // 接口调用
|
|
|
|
|
+ if(!row.dictContent){
|
|
|
|
|
+ ElMessage.warning('请填写类别内容')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ let params = {
|
|
|
|
|
+ id:row.id,
|
|
|
|
|
+ dictName: row.dictName,
|
|
|
|
|
+ dictContent: row.dictContent,
|
|
|
|
|
+ }
|
|
|
|
|
+ let editRes = await editDictionaryApi(params)
|
|
|
|
|
+ if(editRes.code == 200){
|
|
|
|
|
+ ElMessage.success(editRes.msg)
|
|
|
|
|
+ row.dictContent = editRes?.data?.dictContent
|
|
|
|
|
+ HandleConfigCancel(row)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+// 取消配置项操作
|
|
|
|
|
+const HandleConfigCancel = (row)=>{
|
|
|
|
|
+ if(!row.editFlag){
|
|
|
|
|
+ // 不是已有的数据,要删除
|
|
|
|
|
+ tableData.value = tableData.value.filter(item=>{
|
|
|
|
|
+ return item.id !== row.id
|
|
|
|
|
+ })
|
|
|
|
|
+ }else{
|
|
|
|
|
+ row.tmpId = ''
|
|
|
|
|
+ row.editFlag = ''
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 字典删除
|
|
|
|
|
+const HandleConfigDelete = async (row)=>{
|
|
|
|
|
+ dialogVisible.value = true
|
|
|
|
|
+ currentEditRow.value = row
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 2. 参数配置: 删除弹窗 信息
|
|
|
|
|
+*/
|
|
|
|
|
+const dialogVisible = ref(false)
|
|
|
|
|
+const dialogSubmitLoading = ref(false)
|
|
|
|
|
+const currentEditRow = ref()
|
|
|
|
|
+const HandleDialogClose = ()=>{
|
|
|
|
|
+ dialogVisible.value = false
|
|
|
|
|
+ currentEditRow.value = null
|
|
|
|
|
+}
|
|
|
|
|
+const HandleDialogConfirm = async ()=>{
|
|
|
|
|
+ dialogSubmitLoading.value = true
|
|
|
|
|
+ let row = currentEditRow.value
|
|
|
|
|
+ let res = undefined
|
|
|
|
|
+ try{
|
|
|
|
|
+ res = await deleteDictionaryApi(row.id)
|
|
|
|
|
+ }catch{}
|
|
|
|
|
+
|
|
|
|
|
+ if(res?.code == 200){
|
|
|
|
|
+ ElMessage.success(res.msg)
|
|
|
|
|
+ tableData.value = tableData.value.filter(item=>{
|
|
|
|
|
+ return item.id !== row.id
|
|
|
|
|
+ })
|
|
|
|
|
+ HandleDialogClose()
|
|
|
|
|
+ }
|
|
|
|
|
+ dialogSubmitLoading.value = false
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// 动态变更最终表列
|
|
// 动态变更最终表列
|
|
|
watch(()=>props.middleColumnItm,(newVal)=>{
|
|
watch(()=>props.middleColumnItm,(newVal)=>{
|
|
|
if(newVal){
|
|
if(newVal){
|
|
@@ -125,9 +285,9 @@ watch(()=>props.middleColumnItm,(newVal)=>{
|
|
|
{
|
|
{
|
|
|
name:props.middleColumnItm?.name,
|
|
name:props.middleColumnItm?.name,
|
|
|
label:props.middleColumnItm?.label,
|
|
label:props.middleColumnItm?.label,
|
|
|
- width:'100',
|
|
|
|
|
|
|
+ width:'350',
|
|
|
fixed:'',
|
|
fixed:'',
|
|
|
- align:'center',
|
|
|
|
|
|
|
+ align:'left',
|
|
|
minWdth:'',
|
|
minWdth:'',
|
|
|
custom:true,
|
|
custom:true,
|
|
|
},
|
|
},
|
|
@@ -142,7 +302,7 @@ watch(()=>props.middleColumnItm,(newVal)=>{
|
|
|
|
|
|
|
|
// 动态变更表数据
|
|
// 动态变更表数据
|
|
|
watch(()=>props.defaultTableData,(val)=>{
|
|
watch(()=>props.defaultTableData,(val)=>{
|
|
|
- tableData.value = val || []
|
|
|
|
|
|
|
+ tableData.value = JSON.parse(JSON.stringify(val)) || []
|
|
|
},{immediate:true,deep:true})
|
|
},{immediate:true,deep:true})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
@@ -210,6 +370,7 @@ watch(()=>props.defaultTableData,(val)=>{
|
|
|
padding:4px auto;
|
|
padding:4px auto;
|
|
|
text-align: center;
|
|
text-align: center;
|
|
|
border-radius: 6px;
|
|
border-radius: 6px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
|
|
|
:deep(.el-icon){
|
|
:deep(.el-icon){
|
|
|
transform: rotate(45deg);
|
|
transform: rotate(45deg);
|
|
@@ -228,6 +389,7 @@ watch(()=>props.defaultTableData,(val)=>{
|
|
|
:deep(.el-dialog__body){
|
|
:deep(.el-dialog__body){
|
|
|
min-height: 500px !important;
|
|
min-height: 500px !important;
|
|
|
max-height: 500px !important;
|
|
max-height: 500px !important;
|
|
|
|
|
+ padding:20px !important
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|