index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <page-search-table @search="reload"></page-search-table>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. height="calc(100vh - 325px)"
  11. full-height="calc(100vh - 116px)"
  12. tool-class="ele-toolbar-form"
  13. :selection.sync="selection"
  14. :page-size="20"
  15. @columns-change="handleColumnChange"
  16. :cache-key="cacheKeyUrl"
  17. >
  18. <!-- 表头工具栏 -->
  19. <template v-slot:toolbar>
  20. <el-button
  21. size="small"
  22. type="primary"
  23. icon="el-icon-plus"
  24. class="ele-btn-icon"
  25. @click="handleAddOrEdit('','add')"
  26. >
  27. 新建
  28. </el-button>
  29. <el-button
  30. size="small"
  31. type="danger"
  32. el-icon-delete
  33. class="ele-btn-icon"
  34. @click="allDelBtn"
  35. :disabled="selection?.length === 0"
  36. >
  37. 批量删除
  38. </el-button>
  39. </template>
  40. <!-- 操作 -->
  41. <template v-slot:action="{row}">
  42. <!-- <el-link-->
  43. <!-- type="primary"-->
  44. <!-- v-if="[0, 3].includes(row.approvalStatus)"-->
  45. <!-- :underline="false"-->
  46. <!-- icon="el-icon-plus"-->
  47. <!-- @click="sub(row)"-->
  48. <!-- >-->
  49. <!-- 提交-->
  50. <!-- </el-link>-->
  51. <el-link
  52. type="primary"
  53. :underline="false"
  54. icon="el-icon-edit"
  55. @click="handleAddOrEdit(row,'update')"
  56. >
  57. 修改
  58. </el-link>
  59. <el-popconfirm
  60. class="ele-action"
  61. title="确定要删除此信息吗?"
  62. @confirm="remove([row.id])"
  63. >
  64. <template v-slot:reference>
  65. <el-link
  66. type="danger"
  67. :underline="false"
  68. icon="el-icon-delete"
  69. >
  70. 删除
  71. </el-link>
  72. </template>
  73. </el-popconfirm>
  74. </template>
  75. <template v-slot:driverName="{row}">
  76. <el-link
  77. type="primary"
  78. :underline="false"
  79. @click="handleDetail(row,'view')"
  80. >
  81. {{ row.driverName }}
  82. </el-link>
  83. </template>
  84. <!-- <template v-slot:drivingLicenseType="{row}">-->
  85. <!-- {{ getDict('驾照类型', row.drivingLicenseType) }}-->
  86. <!-- </template>-->
  87. </ele-pro-table>
  88. <!-- 多选删除弹窗 -->
  89. <pop-modal
  90. :visible.sync="delVisible"
  91. content="是否确定删除?"
  92. @done="commitBtn"
  93. />
  94. <!-- 新增/修改 -->
  95. <add-or-edit-dialog v-if="addOrEditDialogFlag" :addOrEditDialogFlag.sync="addOrEditDialogFlag"
  96. ref="addOrEditDialogRef" @reload="reload"></add-or-edit-dialog>
  97. <detail-dialog v-if="detailDialogFlag" :detail-dialog-flag.sync="detailDialogFlag"
  98. ref="detailDialogRef"></detail-dialog>
  99. </el-card>
  100. </div>
  101. </template>
  102. <script>
  103. import popModal from '@/components/pop-modal';
  104. import {reviewStatus} from '@/enum/dict';
  105. import dictMixins from "@/mixins/dictMixins";
  106. import pageSearchTable from "./indexSearchTable.vue";
  107. import addOrEditDialog from './components/addOrEditDialog.vue'
  108. import detailDialog from './components/detailDialog.vue'
  109. import {driverBookPageListAPI, driverRemoveAPI, driverSubmit} from "@/api/transportManager/driverBook";
  110. import {mapGetters} from "vuex";
  111. import tabMixins from '@/mixins/tableColumnsMixin';
  112. export default {
  113. mixins: [dictMixins,tabMixins],
  114. components: {
  115. addOrEditDialog,
  116. pageSearchTable,
  117. popModal,
  118. detailDialog
  119. },
  120. data() {
  121. return {
  122. selection: [],
  123. statusList: [
  124. {
  125. label: '空闲',
  126. value: 0,
  127. },
  128. {
  129. label: '派单中',
  130. value: 1,
  131. }
  132. ],
  133. delVisible: false,
  134. // 加载状态
  135. loading: false,
  136. addOrEditDialogFlag: false,
  137. detailDialogFlag: false,
  138. cacheKeyUrl:'eos-8738c576-driverBook',
  139. columnsVersion:1,
  140. };
  141. },
  142. computed: {
  143. ...mapGetters(['dict','getDictValue']),
  144. columns() {
  145. // 当columnsVersion变化时会重新计算,用作更新列配置
  146. const version = this.columnsVersion;
  147. return [
  148. {
  149. width: 45,
  150. type: 'selection',
  151. columnKey: 'selection',
  152. align: 'center'
  153. },
  154. {
  155. columnKey: 'index',
  156. label: '序号',
  157. type: 'index',
  158. width: 55,
  159. align: 'center',
  160. showOverflowTooltip: true,
  161. fixed: 'left'
  162. },
  163. {
  164. prop: 'driverName',
  165. label: '姓名',
  166. align: 'center',
  167. showOverflowTooltip: true,
  168. minWidth: 120,
  169. slot: 'driverName'
  170. },
  171. {
  172. prop: 'sex',
  173. label: '性别',
  174. align: 'center',
  175. showOverflowTooltip: true,
  176. minWidth: 100,
  177. formatter: (_row, _column, cellValue) => {
  178. return cellValue == 1 ? '男' : cellValue == 2 ? '女' : '';
  179. }
  180. },
  181. {
  182. prop: 'age',
  183. label: '年龄',
  184. align: 'center',
  185. showOverflowTooltip: true,
  186. minWidth: 100
  187. },
  188. {
  189. prop: 'phone',
  190. label: '手机号',
  191. align: 'center',
  192. slot: 'phone',
  193. showOverflowTooltip: true,
  194. minWidth: 120,
  195. },
  196. {
  197. prop: 'personId',
  198. label: '身份证号',
  199. align: 'center',
  200. slot: 'personId',
  201. showOverflowTooltip: true,
  202. minWidth: 120,
  203. },
  204. {
  205. prop: 'driverAge',
  206. label: '驾龄',
  207. align: 'center',
  208. slot: 'driverAge',
  209. showOverflowTooltip: true,
  210. minWidth: 100,
  211. },
  212. {
  213. prop: 'drivingLicenseType',
  214. label: '驾驶证类型',
  215. align: 'center',
  216. slot: 'drivingLicenseType',
  217. showOverflowTooltip: true,
  218. formatter: (_row, _column, cellValue) => {
  219. return this.getDict('驾照类型', cellValue)
  220. },
  221. minWidth: 100,
  222. },
  223. {
  224. prop: 'status',
  225. label: '状态',
  226. align: 'center',
  227. slot: 'status',
  228. showOverflowTooltip: true,
  229. minWidth: 100,
  230. formatter: (_row, _column, cellValue) => {
  231. return this.statusList.find(i => i.value == cellValue)?.label;
  232. }
  233. },
  234. {
  235. columnKey: 'action',
  236. label: '操作',
  237. width: 150,
  238. align: 'center',
  239. resizable: false,
  240. slot: 'action',
  241. showOverflowTooltip: true,
  242. fixed: 'right'
  243. }
  244. ]
  245. },
  246. getDict() {
  247. return (dictName, val) => {
  248. return this.getDictValue(dictName, val)
  249. }
  250. }
  251. },
  252. methods: {
  253. //新增、修改
  254. handleAddOrEdit(row = {}, type) {
  255. this.addOrEditDialogFlag = true
  256. this.$nextTick(() => {
  257. this.$refs.addOrEditDialogRef.init(row, type)
  258. })
  259. },
  260. //详情
  261. handleDetail(row = {}, type) {
  262. this.detailDialogFlag = true
  263. this.$nextTick(() => {
  264. this.$refs.detailDialogRef.init(row, type)
  265. })
  266. },
  267. /* 表格数据源 */
  268. datasource({page, limit, where, order}) {
  269. return driverBookPageListAPI({
  270. pageNum: page,
  271. size: limit,
  272. ...where
  273. });
  274. },
  275. /* 刷新表格 */
  276. reload(where) {
  277. this.$nextTick(() => {
  278. this.$refs.table.reload({page: 1, where});
  279. })
  280. },
  281. //批量删除
  282. allDelBtn() {
  283. if (this.selection.length === 0) return;
  284. let flag = this.selection.some(item => [1, 2].includes(item.approvalStatus))
  285. if (flag) return this.$message.warning('抱歉已审核、审核中的数据不能删除,请检查')
  286. this.delVisible = true;
  287. },
  288. commitBtn() {
  289. const dataId = this.selection.map((v) => v.id);
  290. driverRemoveAPI(dataId).then((res) => {
  291. this.$message.success('删除成功!');
  292. this.reload();
  293. });
  294. },
  295. remove(row) {
  296. driverRemoveAPI(row).then((res) => {
  297. this.$message.success('删除成功!');
  298. this.reload();
  299. });
  300. },
  301. sub(res) {
  302. driverSubmit({
  303. businessId: res.id
  304. })
  305. .then((res) => {
  306. this.$message.success('提交成功');
  307. this.reload();
  308. })
  309. .catch((e) => {
  310. this.$message.error(e.message);
  311. });
  312. },
  313. }
  314. };
  315. </script>
  316. <style lang="scss" scoped>
  317. :deep(.el-link--inner) {
  318. margin-left: 0px !important;
  319. }
  320. .sys-organization-list {
  321. height: calc(100vh - 264px);
  322. box-sizing: border-box;
  323. border-width: 1px;
  324. border-style: solid;
  325. overflow: auto;
  326. }
  327. .sys-organization-list :deep(.el-tree-node__content) {
  328. height: 40px;
  329. & > .el-tree-node__expand-icon {
  330. margin-left: 10px;
  331. }
  332. }
  333. </style>