index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <search
  5. class="seep-search"
  6. @search="reload"
  7. @pass-pietype-list="handlePietypeList"
  8. ></search>
  9. <!-- 数据表格 -->
  10. <ele-pro-table
  11. ref="table"
  12. :columns="columns"
  13. :datasource="datasource"
  14. cache-key="systemRoleTable"
  15. :pageSize="20"
  16. >
  17. <!-- 表头工具栏 -->
  18. <template v-slot:toolbar></template>
  19. </ele-pro-table>
  20. </el-card>
  21. </div>
  22. </template>
  23. <script>
  24. import search from './components/search.vue';
  25. import { pageByDispatchRecord } from '@/api/salesServiceManagement/index';
  26. import dictMixins from '@/mixins/dictMixins';
  27. export default {
  28. mixins: [dictMixins],
  29. components: {
  30. search
  31. },
  32. data() {
  33. return {
  34. pietypeList: [],
  35. deptResList: [], // 部门
  36. deptIdToNameMap: {},
  37. // 加载状态
  38. loading: false
  39. };
  40. },
  41. computed: {
  42. columns() {
  43. return [
  44. {
  45. columnKey: 'index',
  46. label: '序号',
  47. type: 'index',
  48. width: 55,
  49. align: 'center',
  50. showOverflowTooltip: true,
  51. fixed: 'left'
  52. },
  53. {
  54. slot: 'demandCode',
  55. prop: 'demandCode',
  56. label: '售后需求编码',
  57. align: 'center',
  58. showOverflowTooltip: true,
  59. minWidth: 200
  60. },
  61. {
  62. prop: 'pieCarType',
  63. label: '派车类型',
  64. align: 'center',
  65. showOverflowTooltip: true,
  66. minWidth: 200,
  67. formatter: (row) => this.getPieTypeLabel(row.pieCarType)
  68. },
  69. {
  70. prop: 'createUserName',
  71. label: '申请人',
  72. align: 'center',
  73. showOverflowTooltip: true,
  74. minWidth: 200,
  75. },
  76. {
  77. prop: 'department',
  78. label: '所属部门',
  79. align: 'center',
  80. minWidth: 300,
  81. showOverflowTooltip: true,
  82. formatter: (row) => {
  83. const deptIds = row.valueJson?.department || [];
  84. return this.getDeptNames(deptIds);
  85. }
  86. },
  87. {
  88. prop: 'subject_matter',
  89. label: '出差事由',
  90. align: 'center',
  91. minWidth: 200,
  92. showOverflowTooltip: true,
  93. formatter: (row) => row.valueJson?.subject_matter || ''
  94. },
  95. {
  96. prop: 'estimated_duration',
  97. label: '预计出差时长',
  98. align: 'center',
  99. minWidth: 200,
  100. showOverflowTooltip: true,
  101. formatter: (row) => row.valueJson?.estimated_duration || ''
  102. },
  103. {
  104. prop: 'travel_time',
  105. label: '出差时间',
  106. align: 'center',
  107. minWidth: 200,
  108. showOverflowTooltip: true,
  109. formatter: (row) => row.valueJson?.travel_time || ''
  110. },
  111. {
  112. prop: 'return_time',
  113. label: '返回时间',
  114. align: 'center',
  115. showOverflowTooltip: true,
  116. minWidth: 200,
  117. formatter: (row) => row.valueJson?.return_time || ''
  118. },
  119. {
  120. prop: 'car_number',
  121. label: '车牌号',
  122. align: 'center',
  123. showOverflowTooltip: true,
  124. minWidth: 200,
  125. formatter: (row) => row.valueJson?.car_number || ''
  126. },
  127. {
  128. prop: 'vehicle_user',
  129. label: '用车人',
  130. align: 'center',
  131. showOverflowTooltip: true,
  132. minWidth: 200,
  133. formatter: (row) => row.valueJson?.vehicle_user || ''
  134. },
  135. {
  136. prop: 'vehicle_mileage',
  137. label: '出差里程数',
  138. align: 'center',
  139. showOverflowTooltip: true,
  140. minWidth: 200,
  141. formatter: (row) => row.valueJson?.vehicle_mileage || ''
  142. },
  143. {
  144. prop: 'return_mileage_to_factory',
  145. label: '返厂里程数',
  146. align: 'center',
  147. showOverflowTooltip: true,
  148. minWidth: 200,
  149. formatter: (row) => row.valueJson?.return_mileage_to_factory || ''
  150. },
  151. {
  152. prop: 'status',
  153. label: '状态',
  154. align: 'center',
  155. showOverflowTooltip: true,
  156. minWidth: 200,
  157. },
  158. {
  159. prop: 'createTime',
  160. label: '创建时间',
  161. align: 'center',
  162. showOverflowTooltip: true,
  163. minWidth: 200,
  164. }
  165. ];
  166. }
  167. },
  168. methods: {
  169. getDeptNames(deptIdArr) {
  170. if (!deptIdArr || !Array.isArray(deptIdArr) || deptIdArr.length === 0) {
  171. return "-";
  172. }
  173. const deptNames = deptIdArr.map(deptId =>
  174. this.deptIdToNameMap[deptId] || ''
  175. );
  176. return deptNames.join("、");
  177. },
  178. getPieTypeLabel(value) {
  179. if (!value) return '';
  180. const target = this.pietypeList.find(item => item.value === String(value));
  181. return target ? target.label : value;
  182. },
  183. handlePietypeList(list, deptRes) {
  184. this.pietypeList = list;
  185. this.deptResList = deptRes;
  186. this.deptIdToNameMap = deptRes.reduce((map, dept) => {
  187. map[dept.id] = dept.name;
  188. return map;
  189. }, {});
  190. },
  191. datasource({ page, limit, where }) {
  192. const dataPromise = pageByDispatchRecord({
  193. pageNum: page,
  194. size: limit,
  195. ...where
  196. });
  197. dataPromise
  198. .then(response => console.log(response))
  199. .catch(error => console.error('获取数据失败:', error));
  200. return dataPromise;
  201. },
  202. /* 刷新表格 */
  203. reload(where) {
  204. this.$refs.table.reload({ page: 1, where });
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. ::v-deep .el-input__inner::placeholder {
  211. font-size: 13px;
  212. }
  213. ::v-deep .seep-search {
  214. .el-input__inner {
  215. padding: 0 5px 0 10px;
  216. }
  217. }
  218. </style>