index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <template>
  2. <div>
  3. <basic-container v-if="!basic">
  4. <avue-crud
  5. :data="data"
  6. ref="crud"
  7. :option="option"
  8. :key="key"
  9. @resetColumn="resetColumn"
  10. @saveColumn="saveColumn"
  11. >
  12. <template slot="menuLeft">
  13. <el-button
  14. type="primary"
  15. size="small"
  16. icon="el-icon-edit"
  17. @click="addDetail"
  18. :disabled="disabled"
  19. v-if="display"
  20. >上传
  21. </el-button>
  22. <slot name="c_button"></slot>
  23. </template>
  24. <template slot="url" slot-scope="{ row }">
  25. <el-input
  26. placeholder="请输入内容"
  27. size="small"
  28. v-if="row.$cellEdit"
  29. v-model="row.url"
  30. class="input-with-select"
  31. >
  32. <el-button slot="append" @click="singleLineUpload(row)"
  33. >附件</el-button
  34. >
  35. </el-input>
  36. <span v-else>{{ row.url }}</span>
  37. </template>
  38. <template slot-scope="scope" slot="menu">
  39. <el-button
  40. icon="el-icon-download"
  41. :size="scope.size"
  42. :type="scope.type"
  43. @click="download(scope)"
  44. >查看
  45. </el-button>
  46. <el-button
  47. :type="scope.type"
  48. :size="scope.size"
  49. icon="el-icon-edit"
  50. @click.stop="rowCell(scope.row, scope.index)"
  51. :disabled="disabled"
  52. >
  53. {{ scope.row.$cellEdit ? "保存" : "修改" }}
  54. </el-button>
  55. <el-button
  56. :type="scope.type"
  57. :size="scope.size"
  58. icon="el-icon-delete"
  59. @click.stop="rowDel(scope.row, scope.index)"
  60. :disabled="disabled"
  61. >删除
  62. </el-button>
  63. </template>
  64. </avue-crud>
  65. <el-dialog
  66. title="上传附件"
  67. append-to-body
  68. :visible.sync="excelBox"
  69. width="555px"
  70. :close-on-click-modal="false"
  71. v-dialog-drag
  72. >
  73. <el-upload
  74. class="upload-demo"
  75. drag
  76. style="text-align: center"
  77. ref="upload"
  78. :action="incomingAction ? incomingAction : action"
  79. :headers="headers"
  80. :on-success="onSuccess"
  81. multiple
  82. >
  83. <i class="el-icon-upload"></i>
  84. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  85. <div class="el-upload__tip" slot="tip">
  86. 如上传文件过大,请耐心等待上传成功
  87. </div>
  88. </el-upload>
  89. </el-dialog>
  90. <el-dialog
  91. title="修改附件"
  92. append-to-body
  93. :visible.sync="excelTwo"
  94. width="555px"
  95. :close-on-click-modal="false"
  96. v-dialog-drag
  97. >
  98. <el-upload
  99. class="upload-demo"
  100. drag
  101. style="text-align: center"
  102. :action="incomingAction ? incomingAction : action"
  103. :headers="headers"
  104. :show-file-list="false"
  105. :on-success="onSuccessTwo"
  106. >
  107. <i class="el-icon-upload"></i>
  108. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  109. <div class="el-upload__tip" slot="tip">
  110. 如上传文件过大,请耐心等待上传成功
  111. </div>
  112. </el-upload>
  113. </el-dialog>
  114. <el-dialog
  115. width="80%"
  116. title="附件"
  117. :visible.sync="innerVisible"
  118. :close-on-click-modal="false"
  119. append-to-body
  120. >
  121. <div style="width: 50%;height: 50%;margin: 0 auto">
  122. <img :src="imgUrl" alt="" style="width: 100%;height: 100%;" />
  123. </div>
  124. </el-dialog>
  125. </basic-container>
  126. <span v-else-if="true">
  127. <avue-crud
  128. :data="data"
  129. ref="crud"
  130. :option="option"
  131. :key="key"
  132. @resetColumn="resetColumn"
  133. @saveColumn="saveColumn"
  134. >
  135. <template slot="menuLeft">
  136. <el-button
  137. type="primary"
  138. size="small"
  139. icon="el-icon-edit"
  140. @click="addDetail"
  141. :disabled="disabled"
  142. >上传
  143. </el-button>
  144. </template>
  145. <template slot="url" slot-scope="{ row }">
  146. <el-input
  147. placeholder="请输入内容"
  148. size="small"
  149. v-if="row.$cellEdit"
  150. v-model="row.url"
  151. class="input-with-select"
  152. >
  153. <el-button slot="append" @click="singleLineUpload(row)"
  154. >附件</el-button
  155. >
  156. </el-input>
  157. <span v-else>{{ row.url }}</span>
  158. </template>
  159. <template slot-scope="scope" slot="menu">
  160. <el-button
  161. icon="el-icon-download"
  162. :size="scope.size"
  163. :type="scope.type"
  164. @click="download(scope)"
  165. >查看
  166. </el-button>
  167. <el-button
  168. :type="scope.type"
  169. :size="scope.size"
  170. icon="el-icon-edit"
  171. @click.stop="rowCell(scope.row, scope.index)"
  172. :disabled="disabled"
  173. >
  174. {{ scope.row.$cellEdit ? "保存" : "修改" }}
  175. </el-button>
  176. <el-button
  177. :type="scope.type"
  178. :size="scope.size"
  179. icon="el-icon-delete"
  180. @click.stop="rowDel(scope.row, scope.index)"
  181. :disabled="disabled"
  182. >删除
  183. </el-button>
  184. </template>
  185. </avue-crud>
  186. <el-dialog
  187. title="上传附件"
  188. append-to-body
  189. :visible.sync="excelBox"
  190. width="555px"
  191. :close-on-click-modal="false"
  192. v-dialog-drag
  193. >
  194. <el-upload
  195. class="upload-demo"
  196. drag
  197. style="text-align: center"
  198. ref="upload"
  199. :action="action"
  200. :headers="headers"
  201. :on-success="onSuccess"
  202. multiple
  203. >
  204. <i class="el-icon-upload"></i>
  205. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  206. <div class="el-upload__tip" slot="tip">
  207. 如上传文件过大,请耐心等待上传成功
  208. </div>
  209. </el-upload>
  210. </el-dialog>
  211. <el-dialog
  212. title="修改附件"
  213. append-to-body
  214. :visible.sync="excelTwo"
  215. width="555px"
  216. :close-on-click-modal="false"
  217. v-dialog-drag
  218. >
  219. <el-upload
  220. class="upload-demo"
  221. drag
  222. style="text-align: center"
  223. :action="incomingAction ? incomingAction : action"
  224. :headers="headers"
  225. :show-file-list="false"
  226. :on-success="onSuccessTwo"
  227. >
  228. <i class="el-icon-upload"></i>
  229. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  230. <div class="el-upload__tip" slot="tip">
  231. 如上传文件过大,请耐心等待上传成功
  232. </div>
  233. </el-upload>
  234. </el-dialog>
  235. <el-dialog
  236. width="80%"
  237. title="附件"
  238. :visible.sync="innerVisible"
  239. :close-on-click-modal="false"
  240. append-to-body
  241. >
  242. <div style="width: 50%;height: 50%;margin: 0 auto">
  243. <img :src="imgUrl" alt="" style="width: 100%;height: 100%;" />
  244. </div>
  245. </el-dialog>
  246. </span>
  247. </div>
  248. </template>
  249. <script>
  250. import { getToken } from "@/util/auth";
  251. import {LTfujianDelete, sharedDeletion} from "@/api/user";
  252. import option from "@/views/exportTrade/customerInquiry/config/mainList.json";
  253. import { gainUser } from "@/api/basicData/customerInquiry";
  254. import { updateListRemove } from "@/api/uploadFile/upload-file";
  255. import {deleteImg} from "../../api/basicData/EquipmentArchives";
  256. export default {
  257. name: "index",
  258. props: {
  259. data: {
  260. type: Object
  261. },
  262. incomingAction: {
  263. type: String
  264. },
  265. deleteUrl: {
  266. type: String
  267. },
  268. enumerationValue: {
  269. type: Number
  270. },
  271. typeUpload: {
  272. type: String
  273. },
  274. disabled: {
  275. type: Boolean
  276. },
  277. display: {
  278. type: Boolean
  279. },
  280. basic: {
  281. type: Boolean
  282. }
  283. },
  284. data() {
  285. return {
  286. excelBox: false,
  287. excelTwo: false,
  288. innerVisible: false,
  289. form: {},
  290. imgUrl: "",
  291. action: "/api/blade-resource/oss/endpoint/put-file",
  292. headers: { "Blade-Auth": "Bearer " + getToken() },
  293. option: {},
  294. key:0,
  295. originalOptions: {
  296. dialogDrag: true,
  297. index: true,
  298. refreshBtn: false,
  299. cellBtn: false,
  300. cancelBtn: false,
  301. delBtn: false,
  302. editBtn: false,
  303. addBtn: false,
  304. align: "center",
  305. column: [
  306. {
  307. label: "文件名称",
  308. prop: "fileName",
  309. index: 1,
  310. width: 140,
  311. cell: true,
  312. overHidden: true
  313. },
  314. {
  315. label: "文件地址",
  316. prop: "url",
  317. index: 2,
  318. overHidden: true
  319. },{
  320. type: "select",
  321. dicUrl: "/api/blade-system/dict-biz/dictionary?code=file_type",
  322. props: {
  323. label: "dictValue",
  324. value: "dictValue"
  325. },
  326. label: "文件属性",
  327. prop: "paymentType",
  328. search: false,
  329. index: 3,
  330. width: 140,
  331. overHidden: true,
  332. cell: true
  333. },
  334. {
  335. label: "备注",
  336. prop: "remarks",
  337. index: 4,
  338. cell: true,
  339. overHidden: true
  340. }
  341. ]
  342. },
  343. originalOptionsTwo: {
  344. dialogDrag: true,
  345. index: true,
  346. refreshBtn: false,
  347. cellBtn: false,
  348. cancelBtn: false,
  349. delBtn: false,
  350. editBtn: false,
  351. addBtn: false,
  352. align: "center",
  353. column: [
  354. {
  355. label: "文件名称",
  356. prop: "fileName",
  357. index: 1,
  358. width: 140,
  359. cell: true,
  360. overHidden: true
  361. },
  362. {
  363. label: "文件地址",
  364. prop: "url",
  365. index: 2,
  366. overHidden: true
  367. },{
  368. type: "select",
  369. dicUrl: "/api/blade-system/dict-biz/dictionary?code=picture_type",
  370. props: {
  371. label: "dictValue",
  372. value: "dictKey"
  373. },
  374. label: "文件属性",
  375. prop: "version",
  376. search: false,
  377. index: 3,
  378. width: 140,
  379. overHidden: true,
  380. cell: true,
  381. },
  382. {
  383. label: "备注",
  384. prop: "remarks",
  385. index: 4,
  386. cell: true,
  387. overHidden: true
  388. }
  389. ]
  390. },
  391. // 基础信息轮胎附件
  392. originalOptionsTwo_LT: {
  393. dialogDrag: true,
  394. index: true,
  395. refreshBtn: false,
  396. cellBtn: false,
  397. cancelBtn: false,
  398. delBtn: false,
  399. editBtn: false,
  400. addBtn: false,
  401. align: "center",
  402. column: [
  403. {
  404. label: "文件名称",
  405. prop: "fileName",
  406. index: 1,
  407. width: 140,
  408. cell: true,
  409. overHidden: true
  410. },
  411. {
  412. label: "文件地址",
  413. prop: "url",
  414. index: 2,
  415. overHidden: true
  416. },{
  417. type: "select",
  418. dicUrl: "/api/blade-system/dict-biz/dictionary?code=picture_type",
  419. props: {
  420. label: "dictValue",
  421. value: "dictKey"
  422. },
  423. label: "文件属性",
  424. prop: "mainImage",
  425. search: false,
  426. index: 3,
  427. width: 140,
  428. overHidden: true,
  429. cell: true,
  430. },
  431. {
  432. label: "备注",
  433. prop: "remarks",
  434. index: 4,
  435. cell: true,
  436. overHidden: true
  437. }
  438. ]
  439. },
  440. originalOptionsThree: {
  441. dialogDrag: true,
  442. index: true,
  443. refreshBtn: false,
  444. cellBtn: false,
  445. cancelBtn: false,
  446. delBtn: false,
  447. editBtn: false,
  448. addBtn: false,
  449. align: "center",
  450. column: [
  451. {
  452. label: "文件名称",
  453. prop: "fileName",
  454. index: 1,
  455. width: 140,
  456. cell: true,
  457. overHidden: true
  458. },
  459. {
  460. label: "文件地址",
  461. prop: "url",
  462. index: 2,
  463. overHidden: true
  464. },
  465. {
  466. label: "备注",
  467. prop: "remarks",
  468. index: 4,
  469. cell: true,
  470. overHidden: true
  471. }
  472. ]
  473. },
  474. uploadCount: 0
  475. };
  476. },
  477. async created() {
  478. /**
  479. * 已定义全局方法,直接使用,getColumnData获取列数据,参数传值(表格名称,引入的本地JSON的数据定义的名称)
  480. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  481. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  482. */
  483. console.log(this.enumerationValue)
  484. if (this.enumerationValue === 160) {
  485. this.option = await this.getColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo);
  486. } else if (this.enumerationValue === 107.1) {
  487. this.option = await this.getColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo);
  488. } else if (this.enumerationValue > 230) {
  489. this.option = await this.getColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo);
  490. } else if (this.enumerationValue === 35.1) {
  491. this.option = await this.getColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsThree);
  492. }else if (this.enumerationValue === 160.1) {
  493. this.option = await this.getColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo_LT);
  494. } else {
  495. this.option = await this.getColumnData(this.getColumnName(this.enumerationValue), this.originalOptions);
  496. this.getWorkDicts("picture_type").then(res => {
  497. if (this.findObject(this.option.column, "version").dicData) {
  498. this.findObject(this.option.column, "version").dicData = res.data.data;
  499. }
  500. });
  501. }
  502. this.key++
  503. },
  504. methods: {
  505. //自定义列保存
  506. async saveColumn() {
  507. /**
  508. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  509. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  510. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  511. */
  512. const inSave = await this.saveColumnData(this.getColumnName(this.enumerationValue),this.option);
  513. if (inSave) {
  514. this.$message.success("保存成功");
  515. //关闭窗口
  516. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  517. }
  518. },
  519. //自定义列重置
  520. async resetColumn() {
  521. if (this.enumerationValue === 160) {
  522. this.option = this.originalOptionsTwo;
  523. const inSave = await this.delColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo);
  524. if (inSave) {
  525. this.$message.success("重置成功");
  526. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  527. }
  528. } else if (this.enumerationValue === 107.1) {
  529. this.option = this.originalOptionsTwo;
  530. const inSave = await this.delColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo);
  531. if (inSave) {
  532. this.$message.success("重置成功");
  533. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  534. }
  535. } else if (this.enumerationValue > 230) {
  536. this.option = this.originalOptionsTwo;
  537. const inSave = await this.delColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo);
  538. if (inSave) {
  539. this.$message.success("重置成功");
  540. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  541. }
  542. } else if (this.enumerationValue === 35.1) {
  543. this.option = this.originalOptionsThree;
  544. const inSave = await this.delColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsThree);
  545. if (inSave) {
  546. this.$message.success("重置成功");
  547. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  548. }
  549. }else if (this.enumerationValue === 160.1) {
  550. this.option = this.originalOptionsTwo_LT;
  551. const inSave = await this.delColumnData(this.getColumnName(this.enumerationValue), this.originalOptionsTwo_LT);
  552. if (inSave) {
  553. this.$message.success("重置成功");
  554. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  555. }
  556. } else {
  557. this.option = this.originalOptions;
  558. const inSave = await this.delColumnData(this.getColumnName(this.enumerationValue), this.originalOptions);
  559. if (inSave) {
  560. this.$message.success("重置成功");
  561. this.getWorkDicts("picture_type").then(res => {
  562. this.findObject(this.option.column, "version").dicData = res.data.data;
  563. });
  564. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  565. }
  566. }
  567. },
  568. //新增上传成功
  569. onSuccess(response, file, fileList) {
  570. this.$refs.crud.rowCellAdd({
  571. fileName: response.data.originalName,
  572. url: response.data.link
  573. });
  574. this.uploadCount++;
  575. if (this.uploadCount === fileList.length) {
  576. this.$refs.upload.clearFiles();
  577. this.excelBox = false;
  578. this.uploadCount = 0;
  579. }
  580. },
  581. //修改上传成功
  582. onSuccessTwo(response) {
  583. this.form.fileName = response.data.originalName;
  584. this.form.url = response.data.link;
  585. this.data[this.form.$index] = this.form;
  586. this.excelTwo = false;
  587. },
  588. //单行上传
  589. singleLineUpload(row) {
  590. this.form = row;
  591. this.excelTwo = true;
  592. },
  593. //开启批量上传
  594. addDetail() {
  595. this.excelBox = true;
  596. },
  597. //下载附件
  598. download(scope) {
  599. if (scope.row.url) {
  600. if (
  601. scope.row.url.substring(scope.row.url.lastIndexOf(".")) ===
  602. ".jpg" ||
  603. scope.row.url.substring(scope.row.url.lastIndexOf(".")) ===
  604. ".png" ||
  605. scope.row.url.substring(scope.row.url.lastIndexOf(".")) ===
  606. ".JPG" ||
  607. scope.row.url.substring(scope.row.url.lastIndexOf(".")) ===
  608. ".PNG"
  609. ) {
  610. this.imgUrl = scope.row.url;
  611. this.innerVisible = true;
  612. } else {
  613. window.open(scope.row.url);
  614. }
  615. } else {
  616. this.$message.error("请上传附件");
  617. }
  618. },
  619. //修改触发
  620. rowCell(row, index) {
  621. if (row.$cellEdit == true) {
  622. this.$set(row, "$cellEdit", false);
  623. } else {
  624. this.$set(row, "$cellEdit", true);
  625. }
  626. // this.$refs.crud.rowCell(row, index)
  627. },
  628. rowDel(row, index) {
  629. this.$confirm("确定将选择数据删除?", {
  630. confirmButtonText: "确定",
  631. cancelButtonText: "取消",
  632. type: "warning"
  633. }).then(() => {
  634. if (row.id) {
  635. if (this.typeUpload == "CK") {
  636. updateListRemove(row.id, this.deleteUrl).then(res => {
  637. if (res.data.success) {
  638. this.$message.success("操作成功!");
  639. this.data.splice(index, 1);
  640. }
  641. });
  642. }else if (this.typeUpload == "LT") {
  643. LTfujianDelete({ids:row.id}).then(res=>{
  644. if (res.data.success) {
  645. this.$message.success("操作成功!");
  646. this.data.splice(index, 1);
  647. }
  648. })
  649. } else if (this.typeUpload == "SBDAFJ") {
  650. deleteImg({ids:row.id}).then(res=>{
  651. if (res.data.success) {
  652. this.$message.success("操作成功!");
  653. this.data.splice(index, 1);
  654. }
  655. })
  656. } else {
  657. sharedDeletion(this.deleteUrl, row.id).then(res => {
  658. if (res.data.success) {
  659. this.$message.success("操作成功!");
  660. this.data.splice(index, 1);
  661. }
  662. });
  663. }
  664. } else {
  665. this.data.splice(index, 1);
  666. }
  667. });
  668. }
  669. }
  670. };
  671. </script>
  672. <style scoped></style>