index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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="urlForm" slot-scope="{ row }">
  19. <el-input
  20. placeholder="文件地址"
  21. size="small"
  22. v-if="row.$cellEdit"
  23. v-model="row.url"
  24. class="input-with-select">
  25. <el-button size="small" type="primary" slot="prepend" @click="download(row)">查看</el-button>
  26. <el-upload
  27. class="upload-demo"
  28. :show-file-list="false"
  29. slot="append"
  30. :action="action"
  31. :headers="headers"
  32. :on-success="(response)=>{onSuccessTwo(response,row)}"
  33. :multiple="false">
  34. <el-button size="small" type="primary">上传</el-button>
  35. </el-upload>
  36. </el-input>
  37. <span v-else>{{ row.url }}</span>
  38. </template>
  39. <template slot-scope="scope" slot="fleetIdForm">
  40. <crop-select v-model="form.fleetId"/>
  41. </template>
  42. <template slot-scope="scope" slot="fleetIdSearch">
  43. <crop-select v-model="form.fleetId"/>
  44. </template>
  45. <template slot-scope="{type,size}" slot="menu">
  46. <el-button icon="el-icon-check" :size="size" :type="type">创建用户</el-button>
  47. </template>
  48. </avue-crud>
  49. </basic-container>
  50. </div>
  51. </template>
  52. <script>
  53. import {getToken} from "@/util/auth";
  54. import {
  55. saveDelegationList,
  56. removeDelegationList,
  57. selectInvoiceList,
  58. detailDelegationList, removeFile
  59. } from "@/api/landTransportation/driver";
  60. export default {
  61. name: "index",
  62. data(){
  63. return{
  64. form:{},
  65. dataList:[],
  66. loading:false,
  67. page: {
  68. pageSize: 10,
  69. currentPage: 1,
  70. total: 0,
  71. pageSizes: [10,50,100,200,300]
  72. },
  73. action: "/api/blade-resource/oss/endpoint/put-file",
  74. headers: { "Blade-Auth": "Bearer " + getToken() },
  75. option:{
  76. align:'center',
  77. dialogWidth:'85%',
  78. index: true,
  79. searchIcon: true,
  80. searchIndex: 2,
  81. searchLabelWidth:100,
  82. searchSpan:8,
  83. column:[{
  84. label: '司机姓名',
  85. prop: 'name',
  86. index: 1,
  87. width: 140,
  88. span: 8,
  89. cell: true,
  90. overHidden: true,
  91. search:true,
  92. },{
  93. label: '身份证号',
  94. prop: 'idCard',
  95. index: 1,
  96. width: 140,
  97. span: 8,
  98. cell: true,
  99. overHidden: true,
  100. search:true,
  101. },{
  102. label: '准驾车型',
  103. prop: 'permitModel',
  104. index: 1,
  105. width: 140,
  106. span: 8,
  107. cell: true,
  108. overHidden: true,
  109. search:true,
  110. },{
  111. label: '电话',
  112. prop: 'tel',
  113. index: 1,
  114. width: 140,
  115. span: 8,
  116. cell: true,
  117. overHidden: true,
  118. search:true,
  119. },{
  120. label: '所属车队',
  121. prop: 'fleetId',
  122. index: 1,
  123. width: 140,
  124. span: 8,
  125. cell: true,
  126. overHidden: true,
  127. search:true,
  128. },{
  129. label: '性别',
  130. prop: 'sex',
  131. index: 1,
  132. width: 140,
  133. span: 8,
  134. cell: true,
  135. overHidden: true,
  136. search:true,
  137. type: 'select',
  138. dicUrl: "/api/blade-system/dict/dictionary?code=sex",
  139. props: {
  140. label: "dictValue",
  141. value: "dictKey"
  142. },
  143. dataType: "number",
  144. },{
  145. label: '驾驶证有效期',
  146. prop: 'driveExpire',
  147. type: "date",
  148. format: 'yyyy-MM-dd',
  149. valueFormat: 'yyyy-MM-dd',
  150. index: 1,
  151. width: 140,
  152. span: 8,
  153. cell: true,
  154. overHidden: true,
  155. search:true,
  156. },{
  157. label: '资格证证件号',
  158. prop: 'qualifiedNo',
  159. index: 1,
  160. width: 140,
  161. span: 8,
  162. cell: true,
  163. overHidden: true,
  164. search:true,
  165. },{
  166. label: '资格证有效期',
  167. prop: 'qualifiedExpire',
  168. type: "date",
  169. format: 'yyyy-MM-dd',
  170. valueFormat: 'yyyy-MM-dd',
  171. index: 1,
  172. width: 140,
  173. span: 8,
  174. cell: true,
  175. overHidden: true,
  176. search:true,
  177. },{
  178. label: '押运证证件号',
  179. prop: 'escortNo',
  180. index: 1,
  181. width: 140,
  182. span: 8,
  183. cell: true,
  184. overHidden: true,
  185. search:true,
  186. },{
  187. label: '押运证有效期',
  188. prop: 'escortExpire',
  189. type: "date",
  190. format: 'yyyy-MM-dd',
  191. valueFormat: 'yyyy-MM-dd',
  192. index: 1,
  193. width: 140,
  194. span: 8,
  195. cell: true,
  196. overHidden: true,
  197. search:true,
  198. },{
  199. label: '附件',
  200. prop: 'fileList',
  201. type: 'dynamic',
  202. span:24,
  203. hide:true,
  204. showColumn:false,
  205. children: {
  206. align: 'center',
  207. headerAlign: 'center',
  208. rowAdd:(done)=>{
  209. // this.$message.success('新增回调');
  210. done()
  211. },
  212. rowDel:(row,done)=>{
  213. if (row.id) {
  214. removeFile(row.id).then(res=>{
  215. done();
  216. })
  217. }else {
  218. done();
  219. }
  220. },
  221. column: [{
  222. width: 200,
  223. label: '文件名称',
  224. prop: "fileName",
  225. formslot: true
  226. }, {
  227. width: 360,
  228. label: '文件地址',
  229. prop: "url"
  230. }, {
  231. width: 200,
  232. label: '文件属性',
  233. type: "select",
  234. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  235. props: {
  236. label: "dictValue",
  237. value: "dictValue"
  238. }
  239. }, {
  240. label: '备注',
  241. prop: "remarks",
  242. }]
  243. }
  244. }]
  245. }
  246. }
  247. },
  248. created() {
  249. let i = 0;
  250. this.option.column.forEach(item => {
  251. if (item.search) i++
  252. })
  253. if (i % 3 !== 0){
  254. const num = 3 - Number(i % 3)
  255. this.option.searchMenuSpan = num * 8;
  256. this.option.searchMenuPosition = "right";
  257. }
  258. },
  259. methods:{
  260. // 获得高度
  261. searchCriteriaSwitch(type){
  262. if (type){
  263. this.option.height = this.option.height - 138
  264. }else {
  265. this.option.height = this.option.height + 138
  266. }
  267. this.$refs.crud.getTableHeight()
  268. },
  269. //附件上传成功
  270. onSuccessTwo(response,row){
  271. row.url = response.data.link
  272. row.fileName = response.data.originalName
  273. },
  274. //下载附件
  275. download(row){
  276. if (row.url){
  277. window.open(row.url)
  278. }else {
  279. this.$message.warning('无附件,请上传附件后再查看');
  280. }
  281. },
  282. //新增
  283. rowSave(row,done,loading){
  284. console.log(row)
  285. saveDelegationList(row).then(res=>{
  286. this.$message.success('保存成功');
  287. this.onLoad(this.page)
  288. done()
  289. }, error => {
  290. window.console.log(error);
  291. loading();
  292. })
  293. },
  294. //点击行编辑时查看
  295. beforeOpen(done,type){
  296. detailDelegationList(this.form.id).then(res=>{
  297. this.form = res.data.data
  298. done()
  299. })
  300. },
  301. //修改
  302. rowUpdate(row,index,done,loading){
  303. saveDelegationList(row).then(res=>{
  304. this.$message.success('保存成功');
  305. this.onLoad(this.page)
  306. loading();
  307. // done()
  308. }, error => {
  309. window.console.log(error);
  310. loading();
  311. })
  312. },
  313. //检索
  314. onLoad(page, params) {
  315. let queryParams = {
  316. size: page.pageSize,
  317. current: page.currentPage,
  318. ...params
  319. }
  320. this.loading = true;
  321. selectInvoiceList(queryParams).then(res => {
  322. this.dataList = res.data.data.records
  323. this.page.total = res.data.data.total
  324. this.option.height = window.innerHeight - 240;
  325. }).finally(() => {
  326. this.loading = false;
  327. })
  328. },
  329. //搜索
  330. searchChange(params,done) {
  331. this.onLoad(this.page,params)
  332. done();
  333. },
  334. //列表删除
  335. rowDel(row){
  336. this.$confirm('此操作将永久删除该单据, 是否继续?', '提示', {
  337. confirmButtonText: '确定',
  338. cancelButtonText: '取消',
  339. type: 'warning'
  340. }).then(() => {
  341. removeDelegationList({ids:row.id}).then(res=>{
  342. this.$message.success('删除成功');
  343. this.onLoad(this.page)
  344. })
  345. }).catch(() => {
  346. this.$message({
  347. type: 'info',
  348. message: '已取消删除'
  349. });
  350. });
  351. },
  352. }
  353. }
  354. </script>
  355. <style scoped>
  356. </style>