index.vue 3.7 KB

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