流程导出

master
lion 8 months ago
parent 84c43b1aba
commit ac67dcc584

@ -2,7 +2,7 @@
<div id="app"> <div id="app">
<router-view /> <router-view />
<ThemePicker style="display: none;"></ThemePicker> <!-- <ThemePicker style="display: none;"></ThemePicker> -->
<OnlineFile></OnlineFile> <OnlineFile></OnlineFile>
</div> </div>
</template> </template>

@ -4,7 +4,7 @@
:z-index="zIndex" :z-index="zIndex"
:value="isShow" :value="isShow"
show-footer show-footer
title="特殊日期" title="导出"
show-confirm-button show-confirm-button
:width="defaultModalSize.width" :width="defaultModalSize.width"
:height="defaultModalSize.height" :height="defaultModalSize.height"
@ -26,9 +26,18 @@
<el-checkbox v-for="field in mainFields" :label="field.name" :key="field.id">{{ field.label }}</el-checkbox> <el-checkbox v-for="field in mainFields" :label="field.name" :key="field.id">{{ field.label }}</el-checkbox>
</el-checkbox-group> </el-checkbox-group>
<!-- <h4>存在子表单</h4> <template v-if="sub2ModelFields.length>0">
<div v-for="field in relationsFields" :key="field.id" style="padding-left: 10px;"> <h4>存在子表单</h4>
<h5>{{ field.label }}</h5> <el-checkbox :indeterminate="isIndeterminate2" v-model="checkAll2" @change="handleCheckAllChange2"></el-checkbox>
<div style="margin: 15px 0;"></div>
<el-checkbox-group v-model="selectedFields2" @change="handleCheckedFieldsChange2">
<el-checkbox v-for="(field,index) in sub2ModelFields" :label="field.name" :key="index">{{ field.label }}</el-checkbox>
</el-checkbox-group>
</template>
<!-- <div v-for="(field,index) in sub2ModelFields" :key="index" style="padding-left: 10px;">
<h5>{{ field }}</h5>
</div> --> </div> -->
</div> </div>
@ -62,15 +71,20 @@ export default {
config: { config: {
fields: [] fields: []
}, },
sub2ModelFields:[],
fileName: `导出_${this.$moment().valueOf()}`, fileName: `导出_${this.$moment().valueOf()}`,
selectedFields: [], selectedFields: [],
checkAll: false, checkAll: false,
isIndeterminate: false, isIndeterminate: false,
//
selectedFields2: [],
checkAll2: false,
isIndeterminate2: false,
} }
}, },
computed: { computed: {
mainFields() { mainFields() {
return this.config?.fields?.filter(i => i.type !== 'relation') return this.config?.fields?.filter(i => i.type !== 'relation' && i.type !== 'file')
}, },
relationsFields() { relationsFields() {
return this.config?.fields?.filter(i => i.type === 'relation') return this.config?.fields?.filter(i => i.type === 'relation')
@ -79,19 +93,29 @@ export default {
methods: { methods: {
handleCheckedFieldsChange(value) { handleCheckedFieldsChange(value) {
let checkedCount = value.length; let checkedCount = value.length;
this.checkAll = checkedCount === this.config?.fields?.length; this.checkAll = checkedCount === this.mainFields?.length;
this.isIndeterminate = checkedCount > 0 && checkedCount < this.config?.fields?.length; this.isIndeterminate = checkedCount > 0 && checkedCount < this.config?.fields?.length;
}, },
handleCheckAllChange(val) { handleCheckAllChange(val) {
this.selectedFields = val ? this.config.fields?.map(i => i.name) : []; this.selectedFields = val ? this.mainFields?.map(i => i.name) : [];
this.isIndeterminate = false; this.isIndeterminate = false;
}, },
handleCheckedFieldsChange2(value) {
let checkedCount = value.length;
this.checkAll2 = checkedCount === this.sub2ModelFields.length;
this.isIndeterminate2 = checkedCount > 0 && checkedCount < this.sub2ModelFields.length;
},
handleCheckAllChange2(val) {
this.selectedFields2 = val ? this.sub2ModelFields?.map(i => i.name) : [];
this.isIndeterminate2 = false;
},
async getFields(id) { async getFields(id) {
try { try {
const { customModel } = await fieldConfig(id) const { customModel } = await fieldConfig(id)
this.config = customModel this.config = customModel
this.config.fields.forEach(i => { this.config.fields.forEach(i => {
i.name = 'data.' + i.name i.name = i.name
}) })
this.fileName = `${customModel.name}_${this.$moment().valueOf()}` this.fileName = `${customModel.name}_${this.$moment().valueOf()}`
} catch (err) { } catch (err) {
@ -140,18 +164,33 @@ export default {
return parts.join('&'); return parts.join('&');
}; };
try { try {
let export_fields = {} let export_fields = {
this.selectedFields?.forEach(field => { 'no':'编号'
let key = field }
export_fields[key] = this.config?.fields?.find(j => j.name === key)?.label if((this.selectedFields && this.selectedFields.length>0) || (this.selectedFields2 && this.selectedFields2.length>0)){
}) this.selectedFields?.forEach(field => {
await download('/api/oa/flow/list-groups', 'get', { let key = field
...this.select, export_fields[key] = this.config?.fields?.find(j => j.name === key)?.label
type: this.$route.params.type, })
is_export: 1, if(this.selectedFields2 && this.selectedFields2.length>0){
export_name: this.fileName, this.selectedFields2?.forEach(field => {
export_fields let key = field
}, this.fileName+'.xlsx', paramsSerializer) export_fields[key] = this.sub2ModelFields?.find(j => j.name === key)?.label
})
}
await download(`/api/oa/flow/list/${this.$route.params.type}`, 'get', {
...this.select,
type: this.$route.params.type,
is_export: 1,
export_name: this.fileName,
export_fields
}, this.fileName+'.xlsx', paramsSerializer)
}else{
// this.$Message.warning("")
return
}
} catch (err) { } catch (err) {
console.error(err) console.error(err)
} }
@ -164,7 +203,7 @@ export default {
} }
}, },
"select.custom_model_id"(newVal) { "select.custom_model_id"(newVal) {
this.getFields(newVal) // this.getFields(newVal)
} }
}, },
} }

@ -25,6 +25,7 @@
filterable filterable
clearable clearable
size="small" size="small"
@change="changeModelId"
v-model="select.custom_model_id" v-model="select.custom_model_id"
> >
<el-option <el-option
@ -34,6 +35,42 @@
:label="item.name" :label="item.name"
></el-option> ></el-option>
</el-select> </el-select>
<!-- 自定义筛选 条件 -->
<el-select
v-if="select.custom_model_id"
style="width: 180px"
filterable
clearable
size="small"
placeholder="字段"
v-model="select.field_id"
>
<el-option
v-for="item in modelsField"
:key="item.id"
:value="item.id"
:label="item.label"
></el-option>
</el-select>
<el-select
v-if="select.custom_model_id"
style="width: 180px"
filterable
clearable
size="small"
placeholder="类型"
v-model="select.operator"
>
<el-option
v-for="item in modelsFieldOpr"
:key="item.id"
:value="item.id"
:label="item.label"
></el-option>
</el-select>
<el-input size="small" style="width: 180px" v-if="select.custom_model_id" v-model="select.field_keyword" placeholder="关键词"></el-input>
<el-select <el-select
style="width: 100px" style="width: 100px"
size="small" size="small"
@ -110,7 +147,7 @@
icon="el-icon-download" icon="el-icon-download"
type="primary" type="primary"
size="small" size="small"
@click="isShowFieldExport = true" @click="showExport"
>导出</el-button >导出</el-button
> >
<!-- <el-button--> <!-- <el-button-->
@ -131,7 +168,7 @@
:key="model.custom_model_id" :key="model.custom_model_id"
:effect="select.custom_model_id === model.custom_model_id ? 'dark' : 'plain'" :effect="select.custom_model_id === model.custom_model_id ? 'dark' : 'plain'"
:type="['success', 'info', 'warning', 'danger'][index%4]" :type="['success', 'info', 'warning', 'danger'][index%4]"
@click="select.custom_model_id = model.custom_model_id,getList()"> @click="select.custom_model_id = model.custom_model_id,getFields(model.custom_model_id),getList()">
{{ model.custom_model ? model.custom_model.name : '' }}{{ model.total }} {{ model.custom_model ? model.custom_model.name : '' }}{{ model.total }}
</el-tag> </el-tag>
</div> </div>
@ -504,12 +541,12 @@
<share ref="share" :is-show.sync="isShowShare" :flow="pickedFlow"></share> <share ref="share" :is-show.sync="isShowShare" :flow="pickedFlow"></share>
<list-popover :is-show.sync="isShowListPopover" :id="listPopoverId" :pos="listPopoverPos" /> <list-popover :is-show.sync="isShowListPopover" :id="listPopoverId" :pos="listPopoverPos" />
<multi-deal :is-show.sync="isShowMultiDeal" :deal-flows="multiDealFlows" @refresh="getList" /> <multi-deal :is-show.sync="isShowMultiDeal" :deal-flows="multiDealFlows" @refresh="getList" />
<field-export :is-show.sync="isShowFieldExport" :select="select" /> <field-export ref="isShowFieldExport" :is-show.sync="isShowFieldExport" :select="select" />
</div> </div>
</template> </template>
<script> <script>
import { flowList, toggleFav, destroy, recall, updateFlowTime, todoTotal } from "@/api/flow"; import { flowList, toggleFav, destroy, recall, updateFlowTime, todoTotal,fieldConfig } from "@/api/flow";
import moment from "moment/moment"; import moment from "moment/moment";
import ListPopover from "./components/ListPopover.vue"; import ListPopover from "./components/ListPopover.vue";
import MultiDeal from "./components/MultiDeal.vue" import MultiDeal from "./components/MultiDeal.vue"
@ -632,13 +669,29 @@ export default {
custom_model_id: "", custom_model_id: "",
date_range: "", date_range: "",
date_type: "create_date", date_type: "create_date",
field_id:'',
operator:'',
field_keyword:''
}, },
loading: false, loading: false,
list: [], list: [],
total: 0, total: 0,
title: "", title: "",
sub2ModelFields:[],
models: [], models: [],
config:{},
modelsField:[],
modelsFieldOpr:[{
id:'eq',
label:'等于'
},{
id:'neq',
label:'不等于'
},{
id:'like',
label:'包含'
}],
dataTypes: [ dataTypes: [
{ {
value: "create_date", value: "create_date",
@ -744,7 +797,31 @@ export default {
} catch (err) {} } catch (err) {}
} }
}, },
changeModelId(e){
console.log("e",e)
this.select.field_id = ''
this.select.operator = ''
this.select.field_keyword = ''
if(e){
this.getFields(e)
this.getList()
}
},
//
showExport(){
this.$refs.isShowFieldExport.config = this.config
this.$refs.isShowFieldExport.sub2ModelFields = this.sub2ModelFields
this.isShowFieldExport = true
},
async getFields(id) {
try {
const { customModel } = await fieldConfig(id)
this.modelsField = customModel.fields
this.config = customModel
} catch (err) {
console.error(id)
}
},
async getList(refresh=false) { async getList(refresh=false) {
if (this.loading) return if (this.loading) return
this.loading = true; this.loading = true;
@ -758,6 +835,13 @@ export default {
this.total = res?.data?.total ?? 0; this.total = res?.data?.total ?? 0;
this.models = res.customModels; this.models = res.customModels;
this.title = res.pageTitle; this.title = res.pageTitle;
if(res.sub2ModelFields instanceof Object){
this.sub2ModelFields = Object.entries(res.sub2ModelFields).map(([key, value]) => ({
label: value,
name: key
}));
}
this.loading = false; this.loading = false;
} catch (err) { } catch (err) {
console.error(err); console.error(err);

Loading…
Cancel
Save