projectListDialog.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <el-dialog
  3. title="选择项目"
  4. :visible.sync="visible"
  5. :before-close="handleClose"
  6. :close-on-click-modal="false"
  7. top="5vh"
  8. v-if="visible"
  9. :close-on-press-escape="false"
  10. append-to-body
  11. width="70%"
  12. >
  13. <el-card shadow="never">
  14. <index-search @search="reload"/>
  15. <ele-pro-table
  16. ref="table"
  17. :columns="columns"
  18. :datasource="datasource"
  19. row-key="id"
  20. height="calc(100vh - 500px)"
  21. class="dict-table"
  22. @cell-click="cellClick"
  23. >
  24. <!-- 表头工具栏 -->
  25. <template v-slot:action="{ row }">
  26. <el-radio class="radio" v-model="radio" :label="row.id"
  27. ><i></i
  28. ></el-radio>
  29. </template>
  30. <template v-slot:status="{ row }">
  31. {{ getDictValue('项目状态', row.status) }}
  32. </template>
  33. <template v-slot:type="{ row }">
  34. {{ getDictValue('项目类型', row.type) }}
  35. </template>
  36. </ele-pro-table>
  37. </el-card>
  38. <div class="btns" slot="footer">
  39. <el-button type="primary" size="small" @click="selected">选择</el-button>
  40. <el-button size="small" @click="handleClose">关闭</el-button>
  41. </div>
  42. </el-dialog>
  43. </template>
  44. <script>
  45. import { projectsPageAPI } from '@/api/pro';
  46. import dictMixins from '@/mixins/dictMixins';
  47. import indexSearch from "./project-search.vue";
  48. export default {
  49. components: {indexSearch},
  50. mixins: [dictMixins],
  51. props: {
  52. contactData: {
  53. type: Object,
  54. default: () => {
  55. return {};
  56. }
  57. }
  58. },
  59. data() {
  60. return {
  61. visible: false,
  62. columns: [
  63. {
  64. columnKey: 'index',
  65. label: '序号',
  66. type: 'index',
  67. width: 55,
  68. align: 'center',
  69. showOverflowTooltip: true,
  70. fixed: 'left'
  71. },
  72. {
  73. action: 'action',
  74. slot: 'action',
  75. align: 'center',
  76. label: '选择'
  77. },
  78. {
  79. prop: 'type',
  80. label: '项目类型',
  81. showOverflowTooltip: true,
  82. minWidth: 150,
  83. align: 'center',
  84. slot: 'type'
  85. },
  86. {
  87. prop: 'code',
  88. label: '项目编码',
  89. showOverflowTooltip: true,
  90. minWidth: 160,
  91. slot: 'code',
  92. align: 'center'
  93. },
  94. {
  95. prop: 'name',
  96. label: '项目名称',
  97. align: 'center',
  98. showOverflowTooltip: true,
  99. minWidth: 140
  100. },
  101. {
  102. prop: 'responsibleDeptName',
  103. label: '负责部门',
  104. align: 'center',
  105. showOverflowTooltip: true,
  106. minWidth: 100
  107. },
  108. {
  109. prop: 'responsibleUserName',
  110. label: '项目经理',
  111. align: 'center',
  112. showOverflowTooltip: true,
  113. minWidth: 100
  114. },
  115. {
  116. prop: 'teamName',
  117. label: '项目团队',
  118. align: 'center',
  119. showOverflowTooltip: true,
  120. minWidth: 100
  121. },
  122. {
  123. prop: 'cycle',
  124. label: '项目周期',
  125. align: 'center',
  126. showOverflowTooltip: true,
  127. minWidth: 100
  128. },
  129. {
  130. prop: 'budget',
  131. label: '项目预算',
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. minWidth: 110,
  135. formatter: (_row, _column, cellValue) => {
  136. return cellValue
  137. ? cellValue + this.getDictValue('预算单位', _row.unit)
  138. : '';
  139. }
  140. },
  141. {
  142. prop: 'planStartDate',
  143. label: '计划开始日期',
  144. align: 'center',
  145. showOverflowTooltip: true,
  146. minWidth: 120
  147. },
  148. {
  149. prop: 'planEndDate',
  150. label: '计划完成日期',
  151. align: 'center',
  152. showOverflowTooltip: true,
  153. minWidth: 120
  154. },
  155. {
  156. prop: 'realStartTime',
  157. label: '实际开始日期',
  158. align: 'center',
  159. showOverflowTooltip: true,
  160. minWidth: 120
  161. },
  162. {
  163. prop: 'realEndTime',
  164. label: '实际完成日期',
  165. align: 'center',
  166. showOverflowTooltip: true,
  167. minWidth: 120
  168. },
  169. {
  170. prop: 'cost',
  171. label: '费用(元)',
  172. align: 'center',
  173. showOverflowTooltip: true,
  174. minWidth: 140
  175. },
  176. {
  177. prop: 'status',
  178. label: '项目状态',
  179. align: 'center',
  180. showOverflowTooltip: true,
  181. minWidth: 100,
  182. slot: 'status'
  183. }
  184. ],
  185. radio: null
  186. };
  187. },
  188. created() {
  189. this.requestDict('项目状态');
  190. this.requestDict('项目类型');
  191. this.requestDict('预算单位');
  192. },
  193. methods: {
  194. open(item) {
  195. if (item && item.id) {
  196. this.radio = item.id;
  197. }
  198. this.visible = true;
  199. },
  200. /* 表格数据源 */
  201. datasource({ page, limit, where, order }) {
  202. if (this.contactData.id) {
  203. where['contactId'] = this.contactData.id;
  204. }
  205. let params = {
  206. pageNum: page,
  207. size: limit,
  208. ...where,
  209. parentId: 0,
  210. processStatus: ['2']
  211. };
  212. return projectsPageAPI(params);
  213. },
  214. /* 刷新表格 */
  215. reload(where) {
  216. this.$refs.table.reload({ pageNum: 1, where: where });
  217. },
  218. // 单击获取id
  219. cellClick(row) {
  220. this.current = row;
  221. console.log(row);
  222. this.radio = row.id;
  223. },
  224. handleClose() {
  225. this.visible = false;
  226. this.current = null;
  227. this.radio = '';
  228. },
  229. async selected() {
  230. if (!this.current) {
  231. return this.$message.warning('请至少选择一条数据');
  232. }
  233. this.$emit('changeParent', this.current, this.currentIndex);
  234. this.handleClose();
  235. }
  236. }
  237. };
  238. </script>
  239. <style lang="scss" scoped>
  240. .tree_col {
  241. border: 1px solid #eee;
  242. padding: 10px 0;
  243. box-sizing: border-box;
  244. height: 500px;
  245. overflow: auto;
  246. }
  247. .table_col {
  248. padding-left: 10px;
  249. ::v-deep .el-table th.el-table__cell {
  250. background: #f2f2f2;
  251. }
  252. }
  253. .pagination {
  254. text-align: right;
  255. padding: 10px 0;
  256. }
  257. .btns {
  258. text-align: center;
  259. padding: 10px 0;
  260. }
  261. .topsearch {
  262. margin-bottom: 15px;
  263. }
  264. </style>