index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <div>
  3. <basic-container v-if="key>0">
  4. <avue-crud
  5. :data="goodsList"
  6. :option="goodsOptionCrud"
  7. :table-loading="loading"
  8. :page.sync="page"
  9. v-model="form"
  10. ref="crud"
  11. @row-save="rowSave"
  12. @row-del="rowDel"
  13. @on-load="onLoad"
  14. @resetColumn="resetColumn"
  15. @saveColumn="saveColumn"
  16. @row-update="(form,index,done,loading)=>{rowSave(form,done)}"
  17. @search-change="searchChange"
  18. @search-criteria-switch="searchCriteriaSwitch">
  19. <template slot-scope="{row,index}" slot="menu">
  20. <el-button
  21. size="small"
  22. type="text"
  23. icon="el-icon-picture-outline"
  24. @click="annexOpen(row, index)"
  25. >附 件
  26. </el-button>
  27. </template>
  28. </avue-crud>
  29. <el-dialog
  30. title="附件"
  31. :visible.sync="dialogVisible"
  32. :close-on-click-modal="false"
  33. append-to-body
  34. width="80%">
  35. <!-- <c-upload-->
  36. <!-- typeUpload="GZ"-->
  37. <!-- :basic="true"-->
  38. <!-- deleteUrl="/api/blade-client/common-file/remove"-->
  39. <!-- :data="orderList"-->
  40. <!-- :disabled="true"-->
  41. <!-- :enumerationValue="76"-->
  42. <!-- ></c-upload>-->
  43. <el-upload
  44. class="hide"
  45. list-type="picture-card"
  46. :on-preview="handlePictureCardPreview"
  47. :action="action"
  48. :file-list="orderList"
  49. :headers="headers"
  50. :on-remove="onRemove"
  51. :on-success="onSuccess"
  52. >
  53. <i class="el-icon-plus"></i>
  54. </el-upload>
  55. <el-dialog :visible.sync="visible" append-to-body>
  56. <img width="100%" :src="dialogImageUrl" alt="">
  57. </el-dialog>
  58. <span slot="footer" class="dialog-footer">
  59. <el-button @click="dialogVisible = false" size="small">取 消</el-button>
  60. <el-button type="primary" @click="saveAnnex" size="small">保 存</el-button>
  61. </span>
  62. </el-dialog>
  63. </basic-container>
  64. </div>
  65. </template>
  66. <script>
  67. import {
  68. driverQueryCollection,
  69. getAttachment,
  70. enclosure, antiepidemicSave,remove
  71. } from "@/api/landTransportation/antiepidemic";
  72. import {getToken} from "@/util/auth";
  73. import {sharedDeletion} from "@/api/user";
  74. import {deleteDetails} from "@/api/basicData/configuration";
  75. export default {
  76. name: "index",
  77. data() {
  78. return {
  79. visible:false,
  80. dialogImageUrl:'',
  81. key:0,
  82. form: {},
  83. orderList:[],
  84. action: "/api/blade-resource/oss/endpoint/put-file",
  85. headers: { "Blade-Auth": "Bearer " + getToken() },
  86. dialogVisible: false,
  87. loading: false,
  88. activeName:'',
  89. page: {
  90. pageSize: 10,
  91. currentPage: 1,
  92. total: 0,
  93. pageSizes: [10, 50, 100, 200, 300]
  94. },
  95. roleName: localStorage.getItem("roleName").split(',')[0],
  96. goodsList: [],
  97. goodsOptionCrud:{},
  98. optionList: {
  99. stripe:true,
  100. index: true,
  101. addBtn: true,
  102. delBtn: true,
  103. cellBtn: false,
  104. cancelBtn: false,
  105. // editBtn: false,
  106. addRowBtn: false,
  107. searchIcon: true,
  108. searchIndex: 2,
  109. searchSpan: 8,
  110. searchMenuPosition: "right",
  111. searchMenuSpan: 6,
  112. align: 'center',
  113. height: "auto",
  114. column: [{
  115. label: '车牌号',
  116. prop: 'plateNo',
  117. overHidden: true,
  118. index: 1,
  119. width: 150,
  120. search: true,
  121. },{
  122. label: '电话',
  123. prop: 'tel',
  124. overHidden: true,
  125. index: 2,
  126. width: 200,
  127. search: true,
  128. },{
  129. label: '制单日期',
  130. type: "date",
  131. searchRange: true,
  132. defaultTime: ['00:00:00', '23:59:59'],
  133. format: "yyyy-MM-dd HH:mm:ss",
  134. valueFormat: "yyyy-MM-dd HH:mm:ss",
  135. prop: 'createTime',
  136. overHidden: true,
  137. display:false,
  138. search: true,
  139. index: 3,
  140. width: 150
  141. },{
  142. label: '箱号一',
  143. prop: 'ctnOne',
  144. overHidden: true,
  145. index: 4,
  146. search: true,
  147. width: 150
  148. },{
  149. label: '箱号二',
  150. prop: 'ctnTwo',
  151. overHidden: true,
  152. index: 5,
  153. search: true,
  154. width: 150
  155. }
  156. ],
  157. },
  158. }
  159. },
  160. async created() {
  161. this.goodsOptionCrud = await this.getColumnData(this.getColumnName(125), this.optionList);
  162. this.key++
  163. let i = 0;
  164. this.goodsOptionCrud.column.forEach(item => {
  165. if (item.search) i++
  166. })
  167. if (i % 3 !== 0) {
  168. const num = 3 - Number(i % 3)
  169. this.goodsOptionCrud.searchMenuSpan = num * 8;
  170. this.goodsOptionCrud.searchMenuPosition = "right";
  171. }
  172. },
  173. methods: {
  174. //删除
  175. rowDel(form,index){
  176. this.$confirm("确定将选择数据删除?", {
  177. confirmButtonText: "确定",
  178. cancelButtonText: "取消",
  179. type: "warning"
  180. }).then(() => {
  181. return remove({ids:form.id});
  182. }).then(() => {
  183. this.$message({
  184. type: "success",
  185. message: "操作成功!"
  186. });
  187. this.page.currentPage = 1;
  188. this.onLoad(this.page, {})
  189. });
  190. },
  191. //新增
  192. rowSave(form,done,loading){
  193. // console.log(this.deepClone(this.form))
  194. antiepidemicSave({
  195. ...this.deepClone(this.form),
  196. fileList:[]
  197. }).then(res=>{
  198. if (res.data.code === 200){
  199. if (this.form.id){
  200. this.$message.success("修改成功");
  201. }else {
  202. this.$message.success("新增成功");
  203. }
  204. this.onLoad(this.page, {})
  205. }
  206. done()
  207. })
  208. },
  209. //保存修改附件
  210. saveAnnex(){
  211. enclosure(this.orderList).then(res=>{
  212. if (res.data.code === 200){
  213. this.$message.success("保存成功");
  214. this.dialogVisible = false
  215. }
  216. })
  217. },
  218. onSuccess(response, file, fileList) {
  219. this.orderList.push({
  220. fileName:response.data.originalName,
  221. url:response.data.link,
  222. pid:this.form.id
  223. })
  224. },
  225. onRemove(file, fileList) {
  226. sharedDeletion('/api/blade-client/common-file/remove', file.id).then(res => {
  227. if (res.data.success) {
  228. this.$message.success("操作成功!");
  229. this.orderList = fileList
  230. }
  231. });
  232. },
  233. handlePictureCardPreview(file) {
  234. this.dialogImageUrl = file.url;
  235. this.visible = true;
  236. },
  237. //自定义列保存
  238. async saveColumn() {
  239. /**
  240. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  241. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  242. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  243. */
  244. const inSave = await this.saveColumnData(this.getColumnName(125), this.goodsOptionCrud);
  245. if (inSave) {
  246. this.$message.success("保存成功");
  247. //关闭窗口
  248. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  249. }
  250. },
  251. //自定义列重置
  252. async resetColumn() {
  253. this.goodsOptionCrud = this.optionList;
  254. const inSave = await this.delColumnData(this.getColumnName(125), this.optionList);
  255. if (inSave) {
  256. this.$message.success("重置成功");
  257. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  258. }
  259. },
  260. // 获得高度
  261. searchCriteriaSwitch(type) {
  262. if (type) {
  263. this.goodsOptionCrud.height = this.goodsOptionCrud.height - 51
  264. } else {
  265. this.goodsOptionCrud.height = this.goodsOptionCrud.height + 51
  266. }
  267. this.$refs.crud.getTableHeight()
  268. },
  269. //打开附件
  270. annexOpen(row, index){
  271. this.orderList = []
  272. this.form = row
  273. getAttachment({id:row.id}).then(res=>{
  274. this.orderList = res.data.data
  275. this.dialogVisible = true
  276. })
  277. },
  278. //搜索
  279. searchChange(params, done) {
  280. let data = params
  281. if (params.arrivalTime) {
  282. data.beginArrivalTime = params.arrivalTime[0]
  283. data.endArrivalTime = params.arrivalTime[1]
  284. }
  285. if (params.createTime) {
  286. data.beginCrateTime = params.createTime[0]
  287. data.endCrateTime = params.createTime[1]
  288. }
  289. delete data.arrivalTime
  290. delete data.createTime
  291. this.onLoad(this.page, params)
  292. done();
  293. },
  294. //查询
  295. onLoad(page, params) {
  296. let queryParams = {
  297. size: page.pageSize,
  298. current: page.currentPage,
  299. ...params
  300. }
  301. this.loading = true;
  302. driverQueryCollection(queryParams).then(res => {
  303. this.goodsList = res.data.data.records
  304. this.page.total = res.data.data.total
  305. this.goodsOptionCrud.height = window.innerHeight - 250;
  306. }).finally(() => {
  307. this.loading = false;
  308. })
  309. },
  310. ToBreak (val) {
  311. if (val)return val.replace(/\n/g, '<br/>')
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. //::v-deep .hide .el-upload--picture-card {
  318. // display: none;
  319. //}
  320. .home-container {
  321. padding: 0px 5px 5px 5px;
  322. box-sizing: border-box;
  323. height: 100%;
  324. ::v-deep .el-card__body {
  325. padding: 10px 15px;
  326. font-size: 14px;
  327. }
  328. &__card {
  329. width: 100%;
  330. height: 100%;
  331. }
  332. .title {
  333. display: flex;
  334. justify-content: space-between;
  335. .right {
  336. display: flex;
  337. align-items: center;
  338. &_but {
  339. margin-right: 10px;
  340. border: 1px solid #409eff;
  341. width: 80px;
  342. border-radius: 3px;
  343. display: flex;
  344. &_left {
  345. width: 40px;
  346. text-align: center;
  347. color: #409eff;
  348. cursor: pointer;
  349. }
  350. &_right {
  351. width: 40px;
  352. text-align: center;
  353. color: #409eff;
  354. cursor: pointer;
  355. }
  356. &_active {
  357. color: #fff;
  358. background-color: #409eff;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. .content {
  365. display: flex;
  366. justify-content: center;
  367. align-items: center;
  368. height: 6vh;
  369. width: 80vw;
  370. .divider {
  371. display: block;
  372. height: 0px;
  373. width: 100%;
  374. border-top: 1px dashed #dcdfe6;
  375. }
  376. &-item {
  377. margin-left: 1vw;
  378. .card {
  379. width: 130px;
  380. display: flex;
  381. align-items: center;
  382. &-title {
  383. width: 40px;
  384. height: 40px;
  385. text-align: center;
  386. border-radius: 50%;
  387. font-size: 20px;
  388. font-weight: 600;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. span {
  393. line-height: 20px;
  394. }
  395. }
  396. &-title1 {
  397. color: #037fe1;
  398. background-color: rgba(3, 127, 225, 0.15);
  399. }
  400. &-title2 {
  401. color: #ffa21e;
  402. background-color: rgba(255, 162, 30, 0.15);
  403. }
  404. &-title3 {
  405. color: #fb5b60;
  406. background-color: rgba(251, 91, 96, 0.15);
  407. }
  408. &-title4 {
  409. color: #42bc6f;
  410. background-color: rgba(66, 1125, 111, 0.15);
  411. }
  412. &-title5 {
  413. color: #14cde1;
  414. background-color: rgba(52, 149, 161, 0.15);
  415. }
  416. &-title6 {
  417. color: rgba(4, 66, 31, 0.63);
  418. background-color: rgba(66, 1125, 111, 0.15);
  419. }
  420. &-content {
  421. padding-left: 1vw;
  422. display: flex;
  423. flex-direction: column;
  424. &-num {
  425. font-size: 20px;
  426. font-weight: 600;
  427. }
  428. &-text {
  429. color: #909399;
  430. }
  431. }
  432. }
  433. }
  434. }
  435. </style>