index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :visible.sync="linkParentDialogFlag"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. top="5vh"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="70%"
  11. >
  12. <el-card shadow="never">
  13. <ele-split-layout
  14. width="200px"
  15. allow-collapse
  16. :right-style="{ overflow: 'hidden' }"
  17. >
  18. <div class="ele-border-lighter split-layout-right-content">
  19. <tree
  20. @handleNodeClick="handleNodeClick"
  21. :isFirstRefreshTable="false"
  22. ref="treeListRef"
  23. :treeList="treeList"
  24. :pid="parentId"
  25. />
  26. </div>
  27. <!-- 表格 -->
  28. <template v-slot:content>
  29. <search @search="reload"></search>
  30. <ele-pro-table
  31. ref="table"
  32. :columns="tableColumns"
  33. :datasource="datasource"
  34. row-key="id"
  35. height="calc(100vh - 430px)"
  36. class="dict-table"
  37. @cell-click="cellClick"
  38. >
  39. <!-- 表头工具栏 -->
  40. <template v-slot:action="{ row }">
  41. <el-radio class="radio" v-model="radio" :label="row.id"
  42. ><i></i
  43. ></el-radio>
  44. </template>
  45. </ele-pro-table>
  46. </template>
  47. </ele-split-layout>
  48. </el-card>
  49. <div slot="footer" class="dialog-footer">
  50. <el-button type="primary" size="small" @click="selected">选择</el-button>
  51. <el-button size="small" @click="handleClose">关闭</el-button>
  52. </div>
  53. </el-dialog>
  54. </template>
  55. <script>
  56. // import DepartmentTree from '@/components/departmentTree';
  57. import { contactPage } from '@/api/custom';
  58. import tree from './components/tree.vue';
  59. import search from './components/search.vue';
  60. import selectPersonDialog from '@/BIZComponents/user-select/user-select.vue';
  61. // import userSelectSearch from '@/BIZComponents/user-select/user-select-search.vue';
  62. import { getByCode } from '@/api/system/dictionary-data';
  63. import { projectsPageAPI } from '@/api/project-manage';
  64. import { reviewStatusEnum } from '@/enum/dict';
  65. export default {
  66. components: {
  67. tree,
  68. selectPersonDialog,
  69. search
  70. },
  71. props: {
  72. parentId: { default: '', type: String },
  73. linkParentDialogFlag: {
  74. type: Boolean,
  75. default: false
  76. },
  77. multiple: {
  78. type: Boolean,
  79. default: false
  80. },
  81. treeApi: {
  82. type: Function,
  83. require: true
  84. },
  85. treeApiCode: {
  86. default: () => ''
  87. },
  88. columns: { default: () => [] },
  89. tableDataApi: {
  90. type: Function,
  91. require: true
  92. },
  93. tableDataParams: {
  94. default: () => {}
  95. }
  96. },
  97. data() {
  98. return {
  99. title: '关联项目',
  100. selection: [],
  101. // columns: [],
  102. treeList: [],
  103. rootId: '',
  104. params: {
  105. type: ''
  106. },
  107. tableColumns: [
  108. {
  109. action: 'action',
  110. slot: 'action',
  111. align: 'center',
  112. label: '选择'
  113. },
  114. {
  115. columnKey: 'index',
  116. label: '序号',
  117. type: 'index',
  118. width: 55,
  119. align: 'center',
  120. showOverflowTooltip: true
  121. },
  122. {
  123. prop: 'typeName',
  124. label: '项目类型',
  125. showOverflowTooltip: true,
  126. minWidth: 150,
  127. align: 'center'
  128. // slot: 'type',
  129. },
  130. {
  131. prop: 'code',
  132. label: '项目编码',
  133. showOverflowTooltip: true,
  134. minWidth: 160,
  135. slot: 'code',
  136. align: 'center'
  137. },
  138. {
  139. prop: 'name',
  140. label: '项目名称',
  141. align: 'center',
  142. showOverflowTooltip: true,
  143. minWidth: 140
  144. },
  145. {
  146. prop: 'responsibleDeptName',
  147. label: '负责部门',
  148. align: 'center',
  149. showOverflowTooltip: true,
  150. minWidth: 100
  151. },
  152. {
  153. prop: 'responsibleUserName',
  154. label: '项目经理',
  155. align: 'center',
  156. showOverflowTooltip: true,
  157. minWidth: 100
  158. },
  159. {
  160. prop: 'teamName',
  161. label: '项目团队',
  162. align: 'center',
  163. showOverflowTooltip: true,
  164. minWidth: 100
  165. },
  166. {
  167. prop: 'cycle',
  168. label: '项目周期',
  169. align: 'center',
  170. showOverflowTooltip: true,
  171. minWidth: 100
  172. },
  173. {
  174. prop: 'budget',
  175. label: '项目预算',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 110,
  179. formatter: (_row, _column, cellValue) => {
  180. return cellValue
  181. ? cellValue +
  182. JSON.parse(
  183. localStorage.getItem('pro_projects_budget_unit')
  184. )[_row.unit].label
  185. : '';
  186. }
  187. },
  188. {
  189. prop: 'planStartDate',
  190. label: '计划开始日期',
  191. align: 'center',
  192. showOverflowTooltip: true,
  193. minWidth: 120
  194. },
  195. {
  196. prop: 'planEndDate',
  197. label: '计划完成日期',
  198. align: 'center',
  199. showOverflowTooltip: true,
  200. minWidth: 120
  201. },
  202. {
  203. prop: 'realStartTime',
  204. label: '实际开始日期',
  205. align: 'center',
  206. showOverflowTooltip: true,
  207. minWidth: 120
  208. },
  209. {
  210. prop: 'realEndTime',
  211. label: '实际完成日期',
  212. align: 'center',
  213. showOverflowTooltip: true,
  214. minWidth: 120
  215. },
  216. {
  217. prop: 'cost',
  218. label: '费用(元)',
  219. align: 'center',
  220. showOverflowTooltip: true,
  221. minWidth: 140
  222. },
  223. {
  224. prop: 'status',
  225. label: '项目状态',
  226. align: 'center',
  227. showOverflowTooltip: true,
  228. minWidth: 100,
  229. slot: 'status'
  230. },
  231. {
  232. prop: 'processStatus',
  233. label: '审核状态',
  234. align: 'center',
  235. showOverflowTooltip: true,
  236. minWidth: 100,
  237. formatter: (_row, _column, cellValue) => {
  238. return reviewStatusEnum[_row.processStatus].label;
  239. }
  240. },
  241. {
  242. prop: 'isOverTime',
  243. label: '是否超时',
  244. align: 'center',
  245. showOverflowTooltip: true,
  246. minWidth: 100,
  247. slot: 'isOverTime'
  248. },
  249. {
  250. prop: 'isOverbudget',
  251. label: '是否超预算',
  252. align: 'center',
  253. showOverflowTooltip: true,
  254. minWidth: 100,
  255. slot: 'isOverbudget'
  256. },
  257. {
  258. prop: 'speedPercent',
  259. label: '项目进度',
  260. align: 'center',
  261. showOverflowTooltip: true,
  262. minWidth: 150,
  263. slot: 'speedPercent'
  264. }
  265. // {
  266. // columnKey: 'action',
  267. // label: '操作',
  268. // width: 280,
  269. // align: 'center',
  270. // resizable: false,
  271. // slot: 'action',
  272. // fixed: 'right'
  273. // }
  274. ],
  275. dictList: [],
  276. radio: null,
  277. current: null,
  278. curNodeData: ''
  279. };
  280. },
  281. methods: {
  282. init() {},
  283. onDone(res) {
  284. console.log(res);
  285. },
  286. handleClose() {
  287. this.$emit('update:linkParentDialogFlag', false);
  288. },
  289. selected() {
  290. this.$emit('linkParent', this.current);
  291. this.handleClose();
  292. },
  293. reload(where) {
  294. console.log(where);
  295. this.$refs.table.reload({ pageNum: 1, where });
  296. // this.$refs.table.reRenderTable();
  297. },
  298. handleNodeClick(data) {
  299. this.params.type = data.id;
  300. this.reload({ type: data.id });
  301. },
  302. cellClick(row) {
  303. console.log('选择');
  304. this.current = row;
  305. this.radio = row.id;
  306. },
  307. async getDictList(code) {
  308. let { data: res1 } = await getByCode('pro_projects_status');
  309. localStorage.setItem('pro_projects_status', JSON.stringify(init(res1)));
  310. let { data: res2 } = await getByCode('pro_projects_type');
  311. localStorage.setItem('pro_projects_type', JSON.stringify(init(res2)));
  312. let { data: res3 } = await getByCode('pro_projects_budget_unit');
  313. localStorage.setItem(
  314. 'pro_projects_budget_unit',
  315. JSON.stringify(init(res3))
  316. );
  317. // this.dictList[code] = res.map((item) => {
  318. // let values = Object.keys(item);
  319. // return {
  320. // value: values[0],
  321. // label: item[values[0]]
  322. // };
  323. // });
  324. function init(data) {
  325. return data.map((item) => {
  326. let values = Object.keys(item);
  327. return {
  328. value: values[0],
  329. label: item[values[0]]
  330. };
  331. });
  332. }
  333. },
  334. /* 表格数据源 */
  335. async datasource({ page, limit, where, order }) {
  336. console.log(this.rootId);
  337. if (this.rootId) {
  338. console.log(this.parentId);
  339. await this.getTreeList();
  340. console.log();
  341. this.$nextTick(() => {
  342. this.$refs.treeListRef.$refs.tree.setCurrentKey(this.parentId);
  343. });
  344. // this.$refs.treeListRef.setCurrentKey(this.parentId)
  345. }
  346. console.log(this.rootId);
  347. this.$refs.treeListRef.$refs.tree.setCurrentKey(this.rootId);
  348. return projectsPageAPI({
  349. pageNum: page,
  350. size: limit,
  351. ...this.params,
  352. ...where
  353. });
  354. return this.tableDataApi({
  355. // pageNum: page,
  356. // size: limit,
  357. // parentId: parent?.id ?? '0',
  358. // // parentId:this.parentId,
  359. ...this.params
  360. // type: this.treeId
  361. });
  362. },
  363. async getTreeList() {
  364. const res = await this.treeApi(this.treeApiCode);
  365. this.treeList = res;
  366. this.rootId = res[0].id;
  367. this.params = { type: this.rootId };
  368. }
  369. },
  370. created() {
  371. this.getTreeList();
  372. this.getDictList();
  373. // this.treeList();
  374. console.log(this.parentId);
  375. // this.radio=this.parentId
  376. // 这里以后可能要带出选择的项,应该是后端返回的数据列表的数据中带一个page的字段,每个子项目在哪个页
  377. },
  378. mounted() {}
  379. };
  380. </script>
  381. <style lang="scss" scoped></style>