Commit 653a7eb6 authored by 何远江's avatar 何远江

添加过滤字段

parent b19ae215
...@@ -158,6 +158,15 @@ export const getVarSpecList = (productCode: any) => { ...@@ -158,6 +158,15 @@ export const getVarSpecList = (productCode: any) => {
}); });
}; };
/**
* 获取过滤映射字段
* @param orderItemId
* @returns
*/
export const getFilterMapField = () => {
return axios.get("/api/completeOrder/getClassFiledsList");
};
/** /**
* checkOrder * checkOrder
......
...@@ -96,6 +96,7 @@ type ExcelChangeStore = { ...@@ -96,6 +96,7 @@ type ExcelChangeStore = {
orderFieldList: Recordable[] orderFieldList: Recordable[]
usedFieldList: Recordable[] usedFieldList: Recordable[]
specList?: Recordable[] specList?: Recordable[]
filterMapField?: Recordable[]
} }
export const useExcelChangeStore = defineStore('excelChangeStore', { export const useExcelChangeStore = defineStore('excelChangeStore', {
...@@ -160,6 +161,7 @@ export const useVariableExcelChangeStore = defineStore('variableExcelChangeStore ...@@ -160,6 +161,7 @@ export const useVariableExcelChangeStore = defineStore('variableExcelChangeStore
scriptList: [], // 脚本 scriptList: [], // 脚本
orderFieldList: [], // 订单字段 orderFieldList: [], // 订单字段
usedFieldList: [], // 当前编辑column使用过的映射字段 usedFieldList: [], // 当前编辑column使用过的映射字段
filterMapField: [] // 变量映射过滤字段
}), }),
getters: { getters: {
getAllMapConfigs(): Recordable { getAllMapConfigs(): Recordable {
...@@ -191,6 +193,10 @@ export const useVariableExcelChangeStore = defineStore('variableExcelChangeStore ...@@ -191,6 +193,10 @@ export const useVariableExcelChangeStore = defineStore('variableExcelChangeStore
}, },
getSpecList(): any { getSpecList(): any {
return this.specList return this.specList
},
getFilterMapFieldsList(): any {
// 是否禁用
return this.filterMapField
} }
}, },
actions: { actions: {
...@@ -211,6 +217,9 @@ export const useVariableExcelChangeStore = defineStore('variableExcelChangeStore ...@@ -211,6 +217,9 @@ export const useVariableExcelChangeStore = defineStore('variableExcelChangeStore
}, },
setSpecList(list: any) { setSpecList(list: any) {
this.specList = list this.specList = list
},
setFilterMapField(list: any) {
this.filterMapField = list
} }
} }
}) })
\ No newline at end of file
...@@ -187,7 +187,8 @@ import { ...@@ -187,7 +187,8 @@ import {
apiVarTemplateGetConf, apiVarTemplateGetConf,
apiVarTemplateConvert, apiVarTemplateConvert,
apiVarTemplateSaveConf, apiVarTemplateSaveConf,
getVarSpecList getVarSpecList,
getFilterMapField
} from '@/api/var' } from '@/api/var'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import type { VxeTableInstance } from 'vxe-table' import type { VxeTableInstance } from 'vxe-table'
...@@ -372,10 +373,14 @@ const toDetail = async (row: any) => { ...@@ -372,10 +373,14 @@ const toDetail = async (row: any) => {
const { data } = await apiVarTemplateGetVars(row.varTemplateDetailId) const { data } = await apiVarTemplateGetVars(row.varTemplateDetailId)
const { data: cdata } = await apiVarTemplateGetConf(row.varTemplateDetailId) const { data: cdata } = await apiVarTemplateGetConf(row.varTemplateDetailId)
const { data: specData } = await getVarSpecList(row.productCode) const { data: specData } = await getVarSpecList(row.productCode)
// 获取过滤字段
const {data: filterData } = await getFilterMapField()
const { res, titles, configs } = filterRunData2(data.result, true) const { res, titles, configs } = filterRunData2(data.result, true)
excelChangeStore.setSpecList(specData.result) excelChangeStore.setSpecList(specData.result)
excelChangeStore.setFilterMapField(filterData.result)
cdata.result?.forEach((item) => { cdata.result?.forEach((item) => {
Reflect.set(configs[item.title], 'filedConfs', item.filedConfs) Reflect.set(configs[item.title], 'filedConfs', item.filedConfs)
......
...@@ -38,7 +38,9 @@ const addFormItem = () => { ...@@ -38,7 +38,9 @@ const addFormItem = () => {
time: Date.now(), time: Date.now(),
mapField: '', mapField: '',
orderFiled: {}, orderFiled: {},
scripts: [] scripts: [],
filterFiled: '',
filterScripts: []
}) })
} }
const removeMapField = (index: number) => { const removeMapField = (index: number) => {
...@@ -49,10 +51,6 @@ const getScriptList = async () => { ...@@ -49,10 +51,6 @@ const getScriptList = async () => {
const { data } = await apiGetScript() const { data } = await apiGetScript()
excelChangeStore.setScriptList(data.result) excelChangeStore.setScriptList(data.result)
} }
const getOrderFields = async () => {
const { data } = await apiGetOrderField()
excelChangeStore.setOrderFieldList(data.result)
}
watch( watch(
...@@ -78,6 +76,5 @@ watch( ...@@ -78,6 +76,5 @@ watch(
onMounted(() => { onMounted(() => {
getScriptList() getScriptList()
getOrderFields()
}) })
</script> </script>
<template> <template>
<!-- 字段映射设置 --> <!-- 字段映射设置 -->
<el-col> <el-col>
<el-form-item label="对应字段" prop="mapField"> <el-form-item label="映射字段" prop="mapField">
<el-select <el-select
v-model="item.mapField" v-model="item.mapField"
style="width: 260px" style="width: 260px"
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<!-- 脚本设置 --> <!-- 脚本设置 -->
<el-col :span="24" v-if="item.mapField"> <el-col :span="24" v-if="item.mapField">
<template v-for="(sitem, idx) in item.scripts"> <template v-for="(sitem, idx) in item.scripts">
<el-form-item :label="'脚本' + (idx ? idx + 1 : '')"> <el-form-item :label="'映射脚本' + (idx ? idx + 1 : '')">
<el-row> <el-row>
<el-col> <el-col>
<el-select <el-select
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
></el-option> ></el-option>
</el-select> </el-select>
<span class="ml-1"> <span class="ml-1">
<el-button v-if="idx == 0" @click="addScript" type="primary" circle <el-button v-if="idx == 0" @click="addScript('scripts')" type="primary" circle
><el-icon><Plus /></el-icon ><el-icon><Plus /></el-icon
></el-button> ></el-button>
<el-button v-if="idx != 0" @click="removeScript(idx)" type="danger" plain circle <el-button v-if="idx != 0" @click="removeScript(idx)" type="danger" plain circle
...@@ -70,6 +70,78 @@ ...@@ -70,6 +70,78 @@
</el-form-item> </el-form-item>
</template> </template>
</el-col> </el-col>
<!-- 过滤字段映射设置 -->
<el-col>
<el-form-item label="过滤字段" prop="filterFiled">
<el-select
v-model="item.filterFiled"
style="width: 260px"
filterable
placeholder="请选择"
clearable
>
<el-option-group
v-for="group in getFilterMapFieldsList"
:key="group.groupTitle"
:label="group.groupTitle"
>
<el-option
v-for="itm in group.filedPojos"
:key="itm.filedName"
:label="itm.fliedTitle"
:value="itm.filedName"
/>
</el-option-group>
</el-select>
</el-form-item>
</el-col>
<!-- 过滤脚本设置 -->
<el-col :span="24" v-if="item.filterFiled">
<template v-for="(sitem, idx) in item.filterScripts">
<el-form-item :label="'过滤脚本' + (idx ? idx + 1 : '')">
<el-row>
<el-col>
<el-select
style="width: 260px"
v-model="sitem.scriptName"
@change="(e) => scriptChange(sitem, e)"
clearable
>
<el-option
v-for="item in getScriptList"
:key="item.srciptName"
:value="item.srciptName"
:label="item.srciptName"
></el-option>
</el-select>
<span class="ml-1">
<el-button v-if="idx == 0" @click="addScript('filterScripts')" type="primary" circle
><el-icon><Plus /></el-icon
></el-button>
<el-button
v-if="idx != 0"
@click="removeScript(idx, 'filterScripts')"
type="danger"
plain
circle
><el-icon><Minus /></el-icon
></el-button>
</span>
</el-col>
<el-col v-if="sitem.scriptName" class="mt-1">
<el-input
type="textarea"
style="width: 270px"
rows="5"
v-model="sitem.content"
></el-input>
</el-col>
</el-row>
</el-form-item>
</template>
</el-col>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -81,9 +153,7 @@ import { onMounted, ref, watch } from 'vue' ...@@ -81,9 +153,7 @@ import { onMounted, ref, watch } from 'vue'
const props = defineProps<{ item?: any; index: number }>() const props = defineProps<{ item?: any; index: number }>()
const emits = defineEmits(['remove']) const emits = defineEmits(['remove'])
const excelChangeStore = useVariableExcelChangeStore() const excelChangeStore = useVariableExcelChangeStore()
const { getScriptList, getSpecList } = storeToRefs(excelChangeStore) const { getScriptList, getSpecList, getFilterMapFieldsList } = storeToRefs(excelChangeStore)
const isVariable = ref(false)
const scriptChange = (sitem, e) => { const scriptChange = (sitem, e) => {
if (e) { if (e) {
...@@ -93,17 +163,11 @@ const scriptChange = (sitem, e) => { ...@@ -93,17 +163,11 @@ const scriptChange = (sitem, e) => {
} }
} }
const checkboxChange = (e) => { const removeScript = (index: number, type = 'scripts') => {
// 设置一个属性 props.item[type].splice(index, 1)
props.item.isVariable = isVariable.value
props.item.mapField = ''
props.item.orderFiled = null
}
const removeScript = (index: number) => {
props.item.scripts.splice(index, 1)
} }
const addScript = () => { const addScript = (type = 'script') => {
props.item.scripts.push({ props.item[type].push({
content: '', content: '',
scriptName: '' scriptName: ''
}) })
...@@ -126,5 +190,18 @@ watch( ...@@ -126,5 +190,18 @@ watch(
} }
} }
) )
watch(
() => props.item.filterFiled,
(val) => {
// 如果有值,添加脚本
if (val && props.item.filterScripts.length == 0) {
props.item.filterScripts.push({
content: '',
scriptName: ''
})
}
}
)
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment