index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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="form.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. },{
  242. label: '身份证号',
  243. prop: 'idCard',
  244. index: 1,
  245. width: 140,
  246. span: 8,
  247. cell: true,
  248. overHidden: true,
  249. search:true,
  250. },{
  251. label: '准驾车型',
  252. prop: 'permitModel',
  253. index: 1,
  254. width: 140,
  255. span: 8,
  256. cell: true,
  257. overHidden: true,
  258. search:true,
  259. },{
  260. label: '电话',
  261. prop: 'tel',
  262. index: 1,
  263. width: 140,
  264. span: 8,
  265. cell: true,
  266. overHidden: true,
  267. search:true,
  268. rules: [{
  269. required: true,
  270. message: " ",
  271. trigger: "blur"
  272. }]
  273. },{
  274. label: '所属车队',
  275. prop: 'fleetId',
  276. index: 1,
  277. width: 140,
  278. span: 8,
  279. cell: true,
  280. overHidden: true,
  281. search:true,
  282. },{
  283. label: '性别',
  284. prop: 'sex',
  285. index: 1,
  286. width: 140,
  287. span: 8,
  288. cell: true,
  289. overHidden: true,
  290. search:true,
  291. type: 'select',
  292. dicUrl: "/api/blade-system/dict/dictionary?code=sex",
  293. props: {
  294. label: "dictValue",
  295. value: "dictKey"
  296. },
  297. dataType: "number",
  298. },{
  299. label: '驾驶证有效期',
  300. prop: 'driveExpire',
  301. type: "date",
  302. format: 'yyyy-MM-dd',
  303. valueFormat: 'yyyy-MM-dd',
  304. index: 1,
  305. width: 140,
  306. span: 8,
  307. cell: true,
  308. overHidden: true,
  309. search:true,
  310. },{
  311. label: '资格证证件号',
  312. prop: 'qualifiedNo',
  313. index: 1,
  314. width: 140,
  315. span: 8,
  316. cell: true,
  317. overHidden: true,
  318. search:true,
  319. },{
  320. label: '资格证有效期',
  321. prop: 'qualifiedExpire',
  322. type: "date",
  323. format: 'yyyy-MM-dd',
  324. valueFormat: 'yyyy-MM-dd',
  325. index: 1,
  326. width: 140,
  327. span: 8,
  328. cell: true,
  329. overHidden: true,
  330. search:true,
  331. },{
  332. label: '押运证证件号',
  333. prop: 'escortNo',
  334. index: 1,
  335. width: 140,
  336. span: 8,
  337. cell: true,
  338. overHidden: true,
  339. search:true,
  340. },{
  341. label: '押运证有效期',
  342. prop: 'escortExpire',
  343. type: "date",
  344. format: 'yyyy-MM-dd',
  345. valueFormat: 'yyyy-MM-dd',
  346. index: 1,
  347. width: 140,
  348. span: 8,
  349. cell: true,
  350. overHidden: true,
  351. search:true,
  352. }, {
  353. label: '信用等级',
  354. width: 150,
  355. span: 8,
  356. prop: 'salesman',
  357. search: true,
  358. overHidden: true,
  359. type: "select",
  360. dicUrl: "/api/blade-system/dict-biz/dictionary?code=credit_rating",
  361. props: {
  362. label: "dictValue",
  363. value: "dictKey"
  364. },
  365. },{
  366. label: '附件',
  367. prop: 'fileList',
  368. type: 'dynamic',
  369. span:24,
  370. hide:true,
  371. showColumn:false,
  372. children: {
  373. align: 'center',
  374. headerAlign: 'center',
  375. rowAdd:(done)=>{
  376. // this.$message.success('新增回调');
  377. done()
  378. },
  379. rowDel:(row,done)=>{
  380. if (row.id) {
  381. removeFile(row.id).then(res=>{
  382. done();
  383. })
  384. }else {
  385. done();
  386. }
  387. },
  388. column: [{
  389. width: 360,
  390. label: '文件地址',
  391. prop: "url"
  392. }, {
  393. width: 200,
  394. label: '文件名称',
  395. prop: "fileName",
  396. formslot: true
  397. },{
  398. width: 200,
  399. label: '文件属性',
  400. type: "select",
  401. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  402. props: {
  403. label: "dictValue",
  404. value: "dictValue"
  405. }
  406. }, {
  407. label: '备注',
  408. prop: "remarks",
  409. }]
  410. }
  411. }]
  412. }
  413. }
  414. },
  415. created() {
  416. let i = 0;
  417. this.option.column.forEach(item => {
  418. if (item.search) i++
  419. })
  420. this.initData(JSON.parse(localStorage.getItem("saber-userInfo")).content.tenant_id)
  421. if (i % 3 !== 0){
  422. const num = 3 - Number(i % 3)
  423. this.option.searchMenuSpan = num * 8;
  424. this.option.searchMenuPosition = "right";
  425. }
  426. },
  427. methods:{
  428. handleImport() {
  429. this.excelBox = true;
  430. },
  431. uploadAfter(res, done, loading, column) {
  432. this.excelBox = false;
  433. this.refreshChange();
  434. done();
  435. },
  436. refreshChange() {
  437. this.onLoad(this.page, {});
  438. },
  439. handleTemplate() {
  440. window.open(`/api/blade-client/land-driver/import-template?${this.website.tokenHeader}=${getToken()}`);
  441. },
  442. //确认创建用户
  443. confirmSynchronization(){
  444. this.$refs['formData'].validate((valid, done) => {
  445. done()
  446. if (valid) {
  447. let data = JSON.parse(JSON.stringify(this.formData))
  448. data.deptId = data.deptId.join(",");
  449. data.roleId = data.roleId.join(",");
  450. data.postId = data.postId.join(",");
  451. driverUser({
  452. ...data,
  453. id:this.formRow.id
  454. }).then(res=>{
  455. this.dialogVisible = false
  456. this.$message.success('创建用户成功,默认帐号:司机名称。默认密码:123456');
  457. })
  458. } else {
  459. return false;
  460. }
  461. });
  462. },
  463. creatingUsers(row){
  464. console.log(row)
  465. if (row.tel){
  466. this.dialogVisible = true
  467. this.formData = {}
  468. this.formRow = row
  469. }else {
  470. this.$message.error('请输入手机号');
  471. }
  472. },
  473. initData(tenantId) {
  474. getRoleTree(tenantId).then(res => {
  475. const column = this.findObject(this.optionData.column, "roleId");
  476. column.dicData = res.data.data;
  477. });
  478. getDeptTree(tenantId).then(res => {
  479. const column = this.findObject(this.optionData.column, "deptId");
  480. column.dicData = res.data.data;
  481. });
  482. getPostList(tenantId).then(res => {
  483. const column = this.findObject(this.optionData.column, "postId");
  484. column.dicData = res.data.data;
  485. });
  486. },
  487. // 获得高度
  488. searchCriteriaSwitch(type){
  489. if (type){
  490. this.option.height = this.option.height - 138
  491. }else {
  492. this.option.height = this.option.height + 138
  493. }
  494. this.$refs.crud.getTableHeight()
  495. },
  496. //附件上传成功
  497. onSuccessTwo(response,row){
  498. row.url = response.data.link
  499. row.fileName = response.data.originalName
  500. },
  501. //下载附件
  502. download(row){
  503. if (row.url){
  504. window.open(row.url)
  505. }else {
  506. this.$message.warning('无附件,请上传附件后再查看');
  507. }
  508. },
  509. //新增
  510. rowSave(row,done,loading){
  511. console.log(row)
  512. saveDelegationList(row).then(res=>{
  513. this.$message.success('保存成功');
  514. this.onLoad(this.page)
  515. done()
  516. }, error => {
  517. window.console.log(error);
  518. loading();
  519. })
  520. },
  521. //点击行编辑时查看
  522. beforeOpen(done,type){
  523. if (this.form.id){
  524. detailDelegationList(this.form.id).then(res=>{
  525. this.form = res.data.data
  526. done()
  527. })
  528. }else {
  529. done()
  530. }
  531. },
  532. //修改
  533. rowUpdate(row,index,done,loading){
  534. saveDelegationList(row).then(res=>{
  535. this.$message.success('保存成功');
  536. this.onLoad(this.page)
  537. loading();
  538. // done()
  539. }, error => {
  540. window.console.log(error);
  541. loading();
  542. })
  543. },
  544. //检索
  545. onLoad(page, params) {
  546. let queryParams = {
  547. size: page.pageSize,
  548. current: page.currentPage,
  549. ...params
  550. }
  551. this.loading = true;
  552. selectInvoiceList(queryParams).then(res => {
  553. this.dataList = res.data.data.records
  554. this.page.total = res.data.data.total
  555. this.option.height = window.innerHeight - 240;
  556. }).finally(() => {
  557. this.loading = false;
  558. })
  559. },
  560. //搜索
  561. searchChange(params,done) {
  562. this.onLoad(this.page,params)
  563. done();
  564. },
  565. //列表删除
  566. rowDel(row){
  567. this.$confirm('此操作将永久删除该单据, 是否继续?', '提示', {
  568. confirmButtonText: '确定',
  569. cancelButtonText: '取消',
  570. type: 'warning'
  571. }).then(() => {
  572. removeDelegationList({ids:row.id}).then(res=>{
  573. this.$message.success('删除成功');
  574. this.onLoad(this.page)
  575. })
  576. }).catch(() => {
  577. this.$message({
  578. type: 'info',
  579. message: '已取消删除'
  580. });
  581. });
  582. },
  583. }
  584. }
  585. </script>
  586. <style scoped>
  587. </style>