index.vue 22 KB

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