| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399 |
- <template>
- <el-dialog
- :title="title"
- :visible.sync="linkParentDialogFlag"
- :before-close="handleClose"
- :close-on-click-modal="false"
- top="5vh"
- :close-on-press-escape="false"
- append-to-body
- width="70%"
- >
- <el-card shadow="never">
- <ele-split-layout
- width="200px"
- allow-collapse
- :right-style="{ overflow: 'hidden' }"
- >
- <div class="ele-border-lighter split-layout-right-content">
- <tree
- @handleNodeClick="handleNodeClick"
- :isFirstRefreshTable="false"
- ref="treeListRef"
- :treeList="treeList"
- :pid="parentId"
- />
- </div>
- <!-- 表格 -->
- <template v-slot:content>
- <search @search="reload"></search>
- <ele-pro-table
- ref="table"
- :columns="tableColumns"
- :datasource="datasource"
- row-key="id"
- height="calc(100vh - 430px)"
- class="dict-table"
- @cell-click="cellClick"
- >
- <!-- 表头工具栏 -->
- <template v-slot:action="{ row }">
- <el-radio class="radio" v-model="radio" :label="row.id"
- ><i></i
- ></el-radio>
- </template>
- </ele-pro-table>
- </template>
- </ele-split-layout>
- </el-card>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" size="small" @click="selected">选择</el-button>
- <el-button size="small" @click="handleClose">关闭</el-button>
- </div>
- </el-dialog>
- </template>
- <script>
- // import DepartmentTree from '@/components/departmentTree';
- import { contactPage } from '@/api/custom';
- import tree from './components/tree.vue';
- import search from './components/search.vue';
- import selectPersonDialog from '@/BIZComponents/user-select/user-select.vue';
- // import userSelectSearch from '@/BIZComponents/user-select/user-select-search.vue';
- import { getByCode } from '@/api/system/dictionary-data';
- import { projectsPageAPI } from '@/api/project-manage';
- import { reviewStatusEnum } from '@/enum/dict';
- export default {
- components: {
- tree,
- selectPersonDialog,
- search
- },
- props: {
- parentId: { default: '', type: String },
- linkParentDialogFlag: {
- type: Boolean,
- default: false
- },
- multiple: {
- type: Boolean,
- default: false
- },
- treeApi: {
- type: Function,
- require: true
- },
- treeApiCode: {
- default: () => ''
- },
- columns: { default: () => [] },
- tableDataApi: {
- type: Function,
- require: true
- },
- tableDataParams: {
- default: () => {}
- }
- },
- data() {
- return {
- title: '关联项目',
- selection: [],
- // columns: [],
- treeList: [],
- rootId: '',
- params: {
- type: ''
- },
- tableColumns: [
- {
- action: 'action',
- slot: 'action',
- align: 'center',
- label: '选择'
- },
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 55,
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'typeName',
- label: '项目类型',
- showOverflowTooltip: true,
- minWidth: 150,
- align: 'center'
- // slot: 'type',
- },
- {
- prop: 'code',
- label: '项目编码',
- showOverflowTooltip: true,
- minWidth: 160,
- slot: 'code',
- align: 'center'
- },
- {
- prop: 'name',
- label: '项目名称',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 140
- },
- {
- prop: 'responsibleDeptName',
- label: '负责部门',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100
- },
- {
- prop: 'responsibleUserName',
- label: '项目经理',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100
- },
- {
- prop: 'teamName',
- label: '项目团队',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100
- },
- {
- prop: 'cycle',
- label: '项目周期',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100
- },
- {
- prop: 'budget',
- label: '项目预算',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 110,
- formatter: (_row, _column, cellValue) => {
- return cellValue
- ? cellValue +
- JSON.parse(
- localStorage.getItem('pro_projects_budget_unit')
- )[_row.unit].label
- : '';
- }
- },
- {
- prop: 'planStartDate',
- label: '计划开始日期',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 120
- },
- {
- prop: 'planEndDate',
- label: '计划完成日期',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 120
- },
- {
- prop: 'realStartTime',
- label: '实际开始日期',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 120
- },
- {
- prop: 'realEndTime',
- label: '实际完成日期',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 120
- },
- {
- prop: 'cost',
- label: '费用(元)',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 140
- },
- {
- prop: 'status',
- label: '项目状态',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100,
- slot: 'status'
- },
- {
- prop: 'processStatus',
- label: '审核状态',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100,
- formatter: (_row, _column, cellValue) => {
- return reviewStatusEnum[_row.processStatus].label;
- }
- },
- {
- prop: 'isOverTime',
- label: '是否超时',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100,
- slot: 'isOverTime'
- },
- {
- prop: 'isOverbudget',
- label: '是否超预算',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 100,
- slot: 'isOverbudget'
- },
- {
- prop: 'speedPercent',
- label: '项目进度',
- align: 'center',
- showOverflowTooltip: true,
- minWidth: 150,
- slot: 'speedPercent'
- }
- // {
- // columnKey: 'action',
- // label: '操作',
- // width: 280,
- // align: 'center',
- // resizable: false,
- // slot: 'action',
- // fixed: 'right'
- // }
- ],
- dictList: [],
- radio: null,
- current: null,
- curNodeData: ''
- };
- },
- methods: {
- init() {},
- onDone(res) {
- console.log(res);
- },
- handleClose() {
- this.$emit('update:linkParentDialogFlag', false);
- },
- selected() {
- this.$emit('linkParent', this.current);
- this.handleClose();
- },
- reload(where) {
- console.log(where);
- this.$refs.table.reload({ pageNum: 1, where });
- // this.$refs.table.reRenderTable();
- },
- handleNodeClick(data) {
- this.params.type = data.id;
- this.reload({ type: data.id });
- },
- cellClick(row) {
- console.log('选择');
- this.current = row;
- this.radio = row.id;
- },
- async getDictList(code) {
- let { data: res1 } = await getByCode('pro_projects_status');
- localStorage.setItem('pro_projects_status', JSON.stringify(init(res1)));
- let { data: res2 } = await getByCode('pro_projects_type');
- localStorage.setItem('pro_projects_type', JSON.stringify(init(res2)));
- let { data: res3 } = await getByCode('pro_projects_budget_unit');
- localStorage.setItem(
- 'pro_projects_budget_unit',
- JSON.stringify(init(res3))
- );
- // this.dictList[code] = res.map((item) => {
- // let values = Object.keys(item);
- // return {
- // value: values[0],
- // label: item[values[0]]
- // };
- // });
- function init(data) {
- return data.map((item) => {
- let values = Object.keys(item);
- return {
- value: values[0],
- label: item[values[0]]
- };
- });
- }
- },
- /* 表格数据源 */
- async datasource({ page, limit, where, order }) {
- console.log(this.rootId);
- if (this.rootId) {
- console.log(this.parentId);
- await this.getTreeList();
- console.log();
- this.$nextTick(() => {
- this.$refs.treeListRef.$refs.tree.setCurrentKey(this.parentId);
- });
- // this.$refs.treeListRef.setCurrentKey(this.parentId)
- }
- console.log(this.rootId);
- this.$refs.treeListRef.$refs.tree.setCurrentKey(this.rootId);
- return projectsPageAPI({
- pageNum: page,
- size: limit,
- ...this.params,
- ...where
- });
- return this.tableDataApi({
- // pageNum: page,
- // size: limit,
- // parentId: parent?.id ?? '0',
- // // parentId:this.parentId,
- ...this.params
- // type: this.treeId
- });
- },
- async getTreeList() {
- const res = await this.treeApi(this.treeApiCode);
- this.treeList = res;
- this.rootId = res[0].id;
- this.params = { type: this.rootId };
- }
- },
- created() {
- this.getTreeList();
- this.getDictList();
- // this.treeList();
- console.log(this.parentId);
- // this.radio=this.parentId
- // 这里以后可能要带出选择的项,应该是后端返回的数据列表的数据中带一个page的字段,每个子项目在哪个页
- },
- mounted() {}
- };
- </script>
- <style lang="scss" scoped></style>
|