index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <script>
  2. import useColumns from "./columns";
  3. import { ITEM } from "@/api/business/purchase/contract";
  4. export default {
  5. name: "SeeFormModel",
  6. props: {
  7. dict: {
  8. type: Object,
  9. },
  10. selectData: {
  11. type: [Array],
  12. require: true,
  13. },
  14. title: {
  15. type: String,
  16. },
  17. },
  18. components: {
  19. ElSuperDescriptions: () =>
  20. import("@/components/super-descriptions/index.vue"),
  21. ElSuperTable: () => import("@/components/super-table/index.vue"),
  22. },
  23. data() {
  24. const {
  25. TabColumns,
  26. TableColumns,
  27. TabColumns: [
  28. {
  29. item: { key: tabName },
  30. },
  31. ],
  32. } = useColumns();
  33. return {
  34. column: 2,
  35. loading: false,
  36. loadingText: "",
  37. params: {},
  38. tabName: tabName,
  39. TabColumns: TabColumns,
  40. TableColumns: TableColumns,
  41. };
  42. },
  43. computed: {
  44. id: {
  45. get() {
  46. const { title, selectData } = this.$props;
  47. const id = title.split("-")[1];
  48. return id ? id : selectData[0].id;
  49. },
  50. set() {},
  51. },
  52. },
  53. watch: {},
  54. methods: {
  55. async fetchItem(prop) {
  56. try {
  57. // try
  58. this.loading = true;
  59. this.loadingText = "获取合同中";
  60. const { code, data } = await ITEM(prop);
  61. if (code === 200) {
  62. this.params = data;
  63. } else {
  64. }
  65. } catch (err) {
  66. // catch
  67. console.error(err);
  68. } finally {
  69. // finally
  70. this.loading = false;
  71. }
  72. },
  73. //
  74. async open(prop) {
  75. this.fetchItem(prop ? prop : this.id);
  76. },
  77. //
  78. async hide() {
  79. this.$emit("close");
  80. },
  81. },
  82. created() {
  83. this.open();
  84. },
  85. mounted() {},
  86. destroyed() {},
  87. };
  88. </script>
  89. <template>
  90. <div
  91. v-loading="loading"
  92. :element-loading-text="loadingText"
  93. style="height: 100vh; display: flex; flex-direction: column"
  94. >
  95. <div
  96. style="
  97. height: 50px;
  98. display: flex;
  99. justify-content: space-between;
  100. align-items: center;
  101. padding: 0 18px;
  102. "
  103. >
  104. <h4 class="m-0" style="font-weight: 500; flex: 1">
  105. {{ title.split("-")[0] }}
  106. </h4>
  107. <el-button
  108. type="primary"
  109. :size="$attrs.size"
  110. :loading="loading"
  111. @click="useSubmit('superForm')"
  112. >确 认</el-button
  113. >
  114. <el-button :size="$attrs.size" :loading="loading" @click="hide"
  115. >取 消</el-button
  116. >
  117. </div>
  118. <div v-if="params.code" style="flex: 1; overflow-y: auto">
  119. <el-super-descriptions
  120. v-if="params.code"
  121. v-model="params"
  122. :dict="dict"
  123. :column="column"
  124. :size="$attrs.size"
  125. :columns="TableColumns"
  126. style="padding: 18px"
  127. >
  128. </el-super-descriptions>
  129. </div>
  130. <el-tabs
  131. v-if="params.code"
  132. v-model="tabName"
  133. :size="$attrs.size"
  134. style="margin: 0 18px 18px"
  135. >
  136. <el-tab-pane
  137. v-for="{ item, TableColumns: columns } in TabColumns"
  138. :key="item.key"
  139. :name="item.key"
  140. :label="item.title"
  141. lazy
  142. >
  143. <div style="height: 25vh; display: flex">
  144. <el-super-table
  145. v-model="params[item.key]"
  146. :size="$attrs.size"
  147. :dict="dict"
  148. :columns="columns"
  149. :iconOperation="false"
  150. >
  151. </el-super-table>
  152. </div>
  153. </el-tab-pane>
  154. </el-tabs>
  155. </div>
  156. </template>