main.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div>
  3. <trade-card title="明细附件" :show="false">
  4. <avue-crud ref="crud" :data="data" :option="tableOption" @row-del="rowDel" @saveColumn="saveColumn"
  5. @resetColumn="resetColumn" :cell-style="cellStyle">
  6. <template slot="menuLeft">
  7. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="addRow">新增
  8. </el-button>
  9. </template>
  10. <template slot="url" slot-scope="{ row }">
  11. <div style="display: flex; justify-content: center">
  12. <el-upload class="upload-demo" :action="uploadImgUrl" :on-success="
  13. (res, file) => {
  14. handleSucces(row, res, file);
  15. }
  16. " :headers="headers" :disabled="disabled" :show-file-list="false" :limit="1">
  17. <el-button size="small" type="text" :disabled="browseStatus">点击上传</el-button>
  18. </el-upload>
  19. </div>
  20. </template>
  21. <template slot-scope="{ row,index}" slot="menu">
  22. <el-button type="text" icon="el-icon-delete" size="small" @click.stop="rowView(row, index)">查看
  23. </el-button>
  24. <el-button type="text" icon="el-icon-delete" size="small" @click.stop="rowDel(row, index)">删除
  25. </el-button>
  26. <el-button type="text" icon="el-icon-delete" size="small" @click.stop="rowDown(row, index)">下载
  27. </el-button>
  28. </template>
  29. </avue-crud>
  30. </trade-card>
  31. </div>
  32. </template>
  33. <script>
  34. import tableOption from "./config/mainList.json";
  35. import { dateFormat } from "@/util/date";
  36. export default {
  37. name: "detailsPageEdit",
  38. data() {
  39. return {
  40. treeStyle: "height:" + (window.innerHeight - 315) + "px",
  41. tableOption: {},
  42. uploadImgUrl: '',
  43. };
  44. },
  45. props: {
  46. data: {
  47. type: Array
  48. },
  49. disabled: {
  50. type: Boolean
  51. }
  52. },
  53. async created() {
  54. this.tableOption = await this.getColumnData(
  55. this.getColumnName(161.3),
  56. tableOption
  57. );
  58. },
  59. methods: {
  60. cellStyle() {
  61. return "padding:0;height:40px;";
  62. },
  63. addRow() {
  64. this.data.push({createBy:this.$store.getters.userInfo.user_name,createTime:dateFormat(new Date()), $cellEdit: true });
  65. },
  66. handleSucces(scope, res, file) {
  67. console.log(scope, res, file)
  68. },
  69. rowCell(row, index) {
  70. if (row.$cellEdit == true) {
  71. this.$set(row, "$cellEdit", false);
  72. } else {
  73. this.$set(row, "$cellEdit", true);
  74. }
  75. },
  76. rowDel(row) {
  77. this.$confirm("确定删除数据?", {
  78. confirmButtonText: "确定",
  79. cancelButtonText: "取消",
  80. type: "warning"
  81. }).then(() => {
  82. this.$message({
  83. type: "success",
  84. message: "删除成功!"
  85. });
  86. this.data.splice(row.$index, 1);
  87. });
  88. },
  89. rowDown(row) {
  90. if (row.url) {
  91. window.open(row.url);
  92. } else {
  93. this.$message.error("请上传附件");
  94. }
  95. },
  96. async saveColumn() {
  97. const inSave = await this.saveColumnData(
  98. this.getColumnName(161.3),
  99. this.tableOption
  100. );
  101. if (inSave) {
  102. this.$nextTick(() => {
  103. this.$refs.crud.doLayout();
  104. });
  105. this.$message.success("保存成功");
  106. //关闭窗口
  107. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  108. }
  109. },
  110. async resetColumn() {
  111. this.tableOption = tableOption;
  112. const inSave = await this.delColumnData(
  113. this.getColumnName(161.3),
  114. tableOption
  115. );
  116. if (inSave) {
  117. this.$nextTick(() => {
  118. this.$refs.crud.doLayout();
  119. });
  120. this.$message.success("重置成功");
  121. //关闭窗口
  122. setTimeout(() => {
  123. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  124. }, 1000);
  125. }
  126. }
  127. },
  128. watch: {
  129. }
  130. };
  131. </script>
  132. <style lang="scss" scoped>
  133. </style>