index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <div>
  3. <basic-container>
  4. <avue-crud
  5. ref="crud"
  6. :data="dataList"
  7. :option="option"
  8. v-model="form"
  9. :table-loading="loading"
  10. :page.sync="page"
  11. @on-load="onLoad"
  12. @row-del="rowDel"
  13. @search-change="searchChange"
  14. @row-update="rowUpdate"
  15. :before-open="beforeOpen"
  16. @search-criteria-switch="searchCriteriaSwitch"
  17. @row-save="rowSave">
  18. <template slot="menuLeft">
  19. <el-button type="primary"
  20. size="small"
  21. icon="el-icon-upload2"
  22. @click="handleImport">导入
  23. </el-button>
  24. </template>
  25. <template slot="urlForm" slot-scope="{ row }">
  26. <el-input
  27. placeholder="文件地址"
  28. size="small"
  29. v-if="row.$cellEdit"
  30. v-model="row.url"
  31. class="input-with-select">
  32. <el-button size="small" type="primary" slot="prepend" @click="download(row)">查看</el-button>
  33. <el-upload
  34. class="upload-demo"
  35. :show-file-list="false"
  36. slot="append"
  37. :action="action"
  38. :headers="headers"
  39. :on-success="(response)=>{onSuccessTwo(response,row)}"
  40. :multiple="false">
  41. <el-button size="small" type="primary">上传</el-button>
  42. </el-upload>
  43. </el-input>
  44. <span v-else>{{ row.url }}</span>
  45. </template>
  46. <template slot-scope="scope" slot="fleetIdForm">
  47. <crop-select corpType="CD" v-model="form.fleetId"/>
  48. </template>
  49. <template slot-scope="scope" slot="fleetIdSearch">
  50. <crop-select corpType="CD" v-model="scope.row.fleetId"/>
  51. </template>
  52. <template slot-scope="scope" slot="fleetId">
  53. <span>{{scope.row.fleetName}}</span>
  54. </template>
  55. <template slot-scope="{type,size,row}" slot="menu">
  56. <el-button icon="el-icon-check" :size="size" :type="type" @click="creatingUsers(row)">创建用户</el-button>
  57. </template>
  58. </avue-crud>
  59. <el-dialog
  60. title="创建用户"
  61. :visible.sync="dialogVisible"
  62. append-to-body
  63. width="60%">
  64. <avue-form ref="formData" v-model="formData" :option="optionData">
  65. </avue-form>
  66. <span slot="footer" class="dialog-footer">
  67. <el-button @click="dialogVisible = false">取 消</el-button>
  68. <el-button type="primary" @click="confirmSynchronization">确 定</el-button>
  69. </span>
  70. </el-dialog>
  71. <el-dialog title="导入"
  72. append-to-body
  73. :visible.sync="excelBox"
  74. width="555px">
  75. <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
  76. <template slot="excelTemplate">
  77. <el-button type="primary" @click="handleTemplate">
  78. 点击下载<i class="el-icon-download el-icon--right"></i>
  79. </el-button>
  80. </template>
  81. </avue-form>
  82. <p style="text-align: center;color: #DC0505">
  83. 温馨提示 第一次导入时请先下载模板
  84. </p>
  85. </el-dialog>
  86. </basic-container>
  87. </div>
  88. </template>
  89. <script>
  90. import {getToken} from "@/util/auth";
  91. import {
  92. saveDelegationList,
  93. removeDelegationList,
  94. selectInvoiceList,
  95. detailDelegationList, removeFile,driverUser
  96. } from "@/api/landTransportation/driver";
  97. import website from "@/config/website";
  98. import {getRoleTree} from "@/api/system/role";
  99. import {getDeptTree} from "@/api/system/dept";
  100. import {getPostList} from "@/api/system/post";
  101. export default {
  102. name: "index",
  103. data(){
  104. return{
  105. form:{},
  106. formRow:{},
  107. dataList:[],
  108. formData:{},
  109. optionData:{
  110. span:8,
  111. menuBtn:false,
  112. column:[{
  113. label: "所属角色",
  114. prop: "roleId",
  115. multiple: true,
  116. type: "tree",
  117. dicData: [],
  118. props: {
  119. label: "title"
  120. },
  121. checkStrictly: true,
  122. slot: true,
  123. rules: [{
  124. required: true,
  125. message: "请选择所属角色",
  126. trigger: "click"
  127. }]
  128. },{
  129. label: "所属部门",
  130. prop: "deptId",
  131. type: "tree",
  132. multiple: true,
  133. dicData: [],
  134. props: {
  135. label: "title"
  136. },
  137. checkStrictly: true,
  138. slot: true,
  139. rules: [{
  140. required: true,
  141. message: "请选择所属部门",
  142. trigger: "click"
  143. }]
  144. },
  145. {
  146. label: "所属岗位",
  147. prop: "postId",
  148. type: "tree",
  149. multiple: true,
  150. dicData: [],
  151. props: {
  152. label: "postName",
  153. value: "id"
  154. },
  155. rules: [{
  156. required: true,
  157. message: "请选择所属岗位",
  158. trigger: "click"
  159. }],
  160. }]
  161. },
  162. excelOption: {
  163. submitBtn: false,
  164. emptyBtn: false,
  165. column: [
  166. // {
  167. // label: "数据覆盖",
  168. // prop: "isCovered",
  169. // type: "switch",
  170. // align: "center",
  171. // width: 80,
  172. // dicData: [
  173. // {
  174. // label: "否",
  175. // value: 0
  176. // },
  177. // {
  178. // label: "是",
  179. // value: 1
  180. // }
  181. // ],
  182. // value: 0,
  183. // slot: true,
  184. // rules: [
  185. // {
  186. // required: true,
  187. // message: "请选择是否覆盖",
  188. // trigger: "blur"
  189. // }
  190. // ]
  191. // },
  192. {
  193. label: '模板下载',
  194. prop: 'excelTemplate',
  195. formslot: true,
  196. span: 24,
  197. },{
  198. label: '模板上传',
  199. prop: 'excelFile',
  200. type: 'upload',
  201. drag: true,
  202. loadText: '模板上传中,请稍等',
  203. span: 24,
  204. propsHttp: {
  205. res: 'data'
  206. },
  207. tip: '请上传 .xls,.xlsx 标准格式文件',
  208. action: "/api/blade-client/land-driver/import-data"
  209. }
  210. ]
  211. },
  212. excelForm:{},
  213. dialogVisible:false,
  214. loading:false,
  215. page: {
  216. pageSize: 10,
  217. currentPage: 1,
  218. total: 0,
  219. pageSizes: [10,50,100,200,300]
  220. },
  221. excelBox:false,
  222. action: "/api/blade-resource/oss/endpoint/put-file",
  223. headers: { "Blade-Auth": "Bearer " + getToken() },
  224. option:{
  225. align:'center',
  226. dialogWidth:'85%',
  227. index: true,
  228. searchIcon: true,
  229. searchIndex: 2,
  230. searchLabelWidth:100,
  231. searchSpan:8,
  232. column:[{
  233. label: '司机姓名',
  234. prop: 'name',
  235. index: 1,
  236. width: 140,
  237. span: 8,
  238. cell: true,
  239. overHidden: true,
  240. search:true,
  241. type: 'select',
  242. filterable:true,
  243. dicUrl: "/api/blade-client/land-driver/driver-list?vehicleId={{key}}",
  244. props: {
  245. label: "name",
  246. value: "name"
  247. },
  248. },{
  249. label: '身份证号',
  250. prop: 'idCard',
  251. index: 1,
  252. width: 140,
  253. span: 8,
  254. cell: true,
  255. overHidden: true,
  256. search:true,
  257. },{
  258. label: '准驾车型',
  259. prop: 'permitModel',
  260. index: 1,
  261. width: 140,
  262. span: 8,
  263. cell: true,
  264. overHidden: true,
  265. search:true,
  266. },{
  267. label: '电话',
  268. prop: 'tel',
  269. index: 1,
  270. width: 140,
  271. span: 8,
  272. cell: true,
  273. overHidden: true,
  274. search:true,
  275. rules: [{
  276. required: true,
  277. message: " ",
  278. trigger: "blur"
  279. }]
  280. },{
  281. label: '所属车队',
  282. prop: 'fleetId',
  283. index: 1,
  284. width: 140,
  285. span: 8,
  286. cell: true,
  287. overHidden: true,
  288. search:true,
  289. },{
  290. label: '性别',
  291. prop: 'sex',
  292. index: 1,
  293. width: 140,
  294. span: 8,
  295. cell: true,
  296. overHidden: true,
  297. search:true,
  298. type: 'select',
  299. dicUrl: "/api/blade-system/dict/dictionary?code=sex",
  300. props: {
  301. label: "dictValue",
  302. value: "dictKey"
  303. },
  304. dataType: "number",
  305. },{
  306. label: '驾驶证有效期',
  307. prop: 'driveExpire',
  308. type: "date",
  309. searchRange: true,
  310. search: true,
  311. span: 8,
  312. searchSpan: 8,
  313. searchDefaultTime: ['00:00:00', '23:59:59'],
  314. format: "yyyy-MM-dd",
  315. valueFormat: "yyyy-MM-dd HH:mm:ss",
  316. index: 1,
  317. width: 140,
  318. },{
  319. label: '资格证证件号',
  320. prop: 'qualifiedNo',
  321. index: 1,
  322. width: 140,
  323. span: 8,
  324. cell: true,
  325. overHidden: true,
  326. search:true,
  327. },{
  328. label: '资格证有效期',
  329. prop: 'qualifiedExpire',
  330. type: "date",
  331. searchRange: true,
  332. search: true,
  333. span: 8,
  334. searchSpan: 8,
  335. searchDefaultTime: ['00:00:00', '23:59:59'],
  336. format: "yyyy-MM-dd",
  337. valueFormat: "yyyy-MM-dd HH:mm:ss",
  338. index: 1,
  339. width: 140
  340. },{
  341. label: '押运证证件号',
  342. prop: 'escortNo',
  343. index: 1,
  344. width: 140,
  345. span: 8,
  346. cell: true,
  347. overHidden: true,
  348. search:true,
  349. },{
  350. label: '押运证有效期',
  351. prop: 'escortExpire',
  352. type: "date",
  353. width: 140,
  354. searchRange: true,
  355. search: true,
  356. span: 8,
  357. searchSpan: 8,
  358. searchDefaultTime: ['00:00:00', '23:59:59'],
  359. format: "yyyy-MM-dd",
  360. valueFormat: "yyyy-MM-dd HH:mm:ss",
  361. }, {
  362. label: '信用等级',
  363. width: 150,
  364. span: 8,
  365. prop: 'salesman',
  366. search: true,
  367. overHidden: true,
  368. type: "select",
  369. dicUrl: "/api/blade-system/dict-biz/dictionary?code=credit_rating",
  370. props: {
  371. label: "dictValue",
  372. value: "dictKey"
  373. },
  374. },{
  375. label: '附件',
  376. prop: 'fileList',
  377. type: 'dynamic',
  378. span:24,
  379. hide:true,
  380. showColumn:false,
  381. children: {
  382. align: 'center',
  383. headerAlign: 'center',
  384. rowAdd:(done)=>{
  385. // this.$message.success('新增回调');
  386. done()
  387. },
  388. rowDel:(row,done)=>{
  389. if (row.id) {
  390. removeFile(row.id).then(res=>{
  391. done();
  392. })
  393. }else {
  394. done();
  395. }
  396. },
  397. column: [{
  398. width: 360,
  399. label: '文件地址',
  400. prop: "url"
  401. }, {
  402. width: 200,
  403. label: '文件名称',
  404. prop: "fileName",
  405. formslot: true
  406. },{
  407. width: 200,
  408. label: '文件属性',
  409. type: "select",
  410. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  411. props: {
  412. label: "dictValue",
  413. value: "dictValue"
  414. }
  415. }, {
  416. label: '备注',
  417. prop: "remarks",
  418. }]
  419. }
  420. }]
  421. }
  422. }
  423. },
  424. created() {
  425. let i = 0;
  426. this.option.column.forEach(item => {
  427. if (item.search) i++
  428. })
  429. this.initData(JSON.parse(localStorage.getItem("saber-userInfo")).content.tenant_id)
  430. if (i % 3 !== 0){
  431. const num = 3 - Number(i % 3)
  432. this.option.searchMenuSpan = num * 8;
  433. this.option.searchMenuPosition = "right";
  434. }
  435. },
  436. methods:{
  437. handleImport() {
  438. this.excelBox = true;
  439. },
  440. uploadAfter(res, done, loading, column) {
  441. this.excelBox = false;
  442. this.refreshChange();
  443. done();
  444. },
  445. refreshChange() {
  446. this.onLoad(this.page, {});
  447. },
  448. handleTemplate() {
  449. window.open(`/api/blade-client/land-driver/import-template?${this.website.tokenHeader}=${getToken()}`);
  450. },
  451. //确认创建用户
  452. confirmSynchronization(){
  453. this.$refs['formData'].validate((valid, done) => {
  454. done()
  455. if (valid) {
  456. let data = JSON.parse(JSON.stringify(this.formData))
  457. data.deptId = data.deptId.join(",");
  458. data.roleId = data.roleId.join(",");
  459. data.postId = data.postId.join(",");
  460. driverUser({
  461. ...data,
  462. id:this.formRow.id
  463. }).then(res=>{
  464. this.dialogVisible = false
  465. this.$message.success('创建用户成功,默认帐号:司机名称。默认密码:123456');
  466. })
  467. } else {
  468. return false;
  469. }
  470. });
  471. },
  472. creatingUsers(row){
  473. console.log(row)
  474. if (row.tel){
  475. this.dialogVisible = true
  476. this.formData = {}
  477. this.formRow = row
  478. }else {
  479. this.$message.error('请输入手机号');
  480. }
  481. },
  482. initData(tenantId) {
  483. getRoleTree(tenantId).then(res => {
  484. const column = this.findObject(this.optionData.column, "roleId");
  485. column.dicData = res.data.data;
  486. });
  487. getDeptTree(tenantId).then(res => {
  488. const column = this.findObject(this.optionData.column, "deptId");
  489. column.dicData = res.data.data;
  490. });
  491. getPostList(tenantId).then(res => {
  492. const column = this.findObject(this.optionData.column, "postId");
  493. column.dicData = res.data.data;
  494. });
  495. },
  496. // 获得高度
  497. searchCriteriaSwitch(type){
  498. if (type){
  499. this.option.height = this.option.height - 138
  500. }else {
  501. this.option.height = this.option.height + 138
  502. }
  503. this.$refs.crud.getTableHeight()
  504. },
  505. //附件上传成功
  506. onSuccessTwo(response,row){
  507. row.url = response.data.link
  508. row.fileName = response.data.originalName
  509. },
  510. //下载附件
  511. download(row){
  512. if (row.url){
  513. window.open(row.url)
  514. }else {
  515. this.$message.warning('无附件,请上传附件后再查看');
  516. }
  517. },
  518. //新增
  519. rowSave(row,done,loading){
  520. console.log(row)
  521. saveDelegationList(row).then(res=>{
  522. this.$message.success('保存成功');
  523. this.onLoad(this.page)
  524. done()
  525. }, error => {
  526. window.console.log(error);
  527. loading();
  528. })
  529. },
  530. //点击行编辑时查看
  531. beforeOpen(done,type){
  532. if (this.form.id){
  533. detailDelegationList(this.form.id).then(res=>{
  534. this.form = res.data.data
  535. done()
  536. })
  537. }else {
  538. done()
  539. }
  540. },
  541. //修改
  542. rowUpdate(row,index,done,loading){
  543. saveDelegationList(row).then(res=>{
  544. this.$message.success('保存成功');
  545. this.onLoad(this.page)
  546. loading();
  547. // done()
  548. }, error => {
  549. window.console.log(error);
  550. loading();
  551. })
  552. },
  553. //检索
  554. onLoad(page, params) {
  555. let queryParams = {
  556. size: page.pageSize,
  557. current: page.currentPage,
  558. ...this.query
  559. }
  560. this.loading = true;
  561. selectInvoiceList(queryParams).then(res => {
  562. this.dataList = res.data.data.records
  563. this.page.total = res.data.data.total
  564. this.option.height = window.innerHeight - 240;
  565. }).finally(() => {
  566. this.loading = false;
  567. })
  568. },
  569. //搜索
  570. searchChange(params,done) {
  571. let data = params
  572. if (data.driveExpire){
  573. data.beginDriveExpire = data.driveExpire[0]
  574. data.endDriveExpire = data.driveExpire[1]
  575. }
  576. if (data.qualifiedExpire){
  577. data.beginQualifiedExpire = data.qualifiedExpire[0]
  578. data.endQualifiedExpire = data.qualifiedExpire[1]
  579. }
  580. if (data.escortExpire){
  581. data.beginEscortExpire = data.escortExpire[0]
  582. data.endEscortExpire = data.escortExpire[1]
  583. }
  584. delete data.driveExpire
  585. delete data.qualifiedExpire
  586. delete data.escortExpire
  587. this.query = data
  588. this.onLoad(this.page,data)
  589. done();
  590. },
  591. //列表删除
  592. rowDel(row){
  593. this.$confirm('此操作将永久删除该单据, 是否继续?', '提示', {
  594. confirmButtonText: '确定',
  595. cancelButtonText: '取消',
  596. type: 'warning'
  597. }).then(() => {
  598. removeDelegationList({ids:row.id}).then(res=>{
  599. this.$message.success('删除成功');
  600. this.onLoad(this.page)
  601. })
  602. }).catch(() => {
  603. this.$message({
  604. type: 'info',
  605. message: '已取消删除'
  606. });
  607. });
  608. },
  609. }
  610. }
  611. </script>
  612. <style scoped>
  613. </style>