index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <script>
  2. import Column from "./column";
  3. import useData from "../hooks/data";
  4. import useDicts from "../hooks/dicts";
  5. import { ITEM } from "@/api/business/purchase/contract";
  6. export default {
  7. name: "SeeDrawer",
  8. dicts: useDicts(Column),
  9. components: {},
  10. data() {
  11. return {
  12. column: 3,
  13. title: "明 细",
  14. ...useData(Column),
  15. };
  16. },
  17. computed: {
  18. root: function () {
  19. return this.$parent.$parent;
  20. },
  21. },
  22. watch: {},
  23. methods: {
  24. async fetchItem(prop) {
  25. try {
  26. // try
  27. this.loading = true;
  28. const { code, data } = await ITEM(prop);
  29. if (code === 200) {
  30. this.params = data;
  31. this.tabName = this.tabColumns[0].key;
  32. return true;
  33. } else {
  34. return false;
  35. }
  36. } catch (err) {
  37. // catch
  38. console.error(err);
  39. } finally {
  40. // finally
  41. this.loading = false;
  42. }
  43. },
  44. //
  45. async open(prop) {
  46. this.visible = await this.fetchItem(prop);
  47. },
  48. //
  49. async hide() {
  50. this.visible = false;
  51. },
  52. //
  53. async useDelete(prop) {
  54. await this.root
  55. .useDelete(prop)
  56. .then(() => {
  57. this.hide();
  58. })
  59. .catch(() => {});
  60. },
  61. //
  62. async useTermination(prop) {
  63. await this.root
  64. .useTermination(prop)
  65. .then(() => {
  66. this.fetchItem(this.params.id);
  67. })
  68. .catch(() => {});
  69. },
  70. },
  71. created() {},
  72. mounted() {},
  73. destroyed() {},
  74. };
  75. </script>
  76. <template>
  77. <el-drawer
  78. :size="width"
  79. :title="title"
  80. :show-close="false"
  81. :visible.sync="visible"
  82. >
  83. <template slot="title">
  84. <span>{{ title }}</span>
  85. <span>
  86. <el-tooltip
  87. v-if="root.hasPowerDelete([params])"
  88. effect="dark"
  89. content="删 除"
  90. placement="bottom-end"
  91. >
  92. <el-button
  93. :size="size"
  94. circle
  95. icon="el-icon-delete"
  96. @click="useDelete([params])"
  97. ></el-button>
  98. </el-tooltip>
  99. <el-tooltip
  100. v-if="root.hasPowerEdit([params])"
  101. effect="dark"
  102. content="编 辑"
  103. placement="bottom-end"
  104. >
  105. <el-button
  106. :size="size"
  107. circle
  108. icon="el-icon-edit"
  109. @click="root.useEdit([params])"
  110. ></el-button>
  111. </el-tooltip>
  112. <el-tooltip
  113. v-if="root.hasPowerTermination([params])"
  114. effect="dark"
  115. content="终 止"
  116. placement="bottom-end"
  117. >
  118. <el-button
  119. :size="size"
  120. circle
  121. icon="el-icon-light-rain"
  122. @click="useTermination([params])"
  123. ></el-button>
  124. </el-tooltip>
  125. <el-tooltip
  126. v-if="root.hasPowerPigeonhole([params])"
  127. effect="dark"
  128. content="归 档"
  129. placement="bottom-end"
  130. >
  131. <el-button
  132. :size="size"
  133. circle
  134. icon="el-icon-lightning"
  135. @click="root.usePigeonhole([params])"
  136. ></el-button>
  137. </el-tooltip>
  138. <el-tooltip
  139. v-if="root.hasPowerSubmit([params])"
  140. effect="dark"
  141. content="提交OA"
  142. placement="bottom-end"
  143. >
  144. <el-button
  145. :size="size"
  146. circle
  147. icon="el-icon-heavy-rain"
  148. @click="root.useSubmit([params])"
  149. ></el-button>
  150. </el-tooltip>
  151. <el-button
  152. :size="size"
  153. circle
  154. type="danger"
  155. icon="el-icon-close"
  156. @click="hide"
  157. ></el-button>
  158. </span>
  159. </template>
  160. <el-descriptions :size="size" :column="column" border style="margin: 10px">
  161. <el-descriptions-item
  162. v-if="params[column.key]"
  163. v-for="(column, index) in formColumns"
  164. :key="index"
  165. :label="column.title"
  166. :labelStyle="{ width: '150px' }"
  167. :contentStyle="{ width: 'auto' }"
  168. >
  169. <dict-tag
  170. v-if="column.inputType === 'Select'"
  171. :size="size"
  172. :value="params[column.key]"
  173. :options="dict.type[column.referName]"
  174. />
  175. <span v-else-if="column.inputType === 'Upload'">
  176. <dr-file-preview v-model="params[column.key]"></dr-file-preview>
  177. </span>
  178. <span v-else>{{ params[column.key] }}</span>
  179. </el-descriptions-item>
  180. </el-descriptions>
  181. <el-tabs v-model="tabName" :size="size" style="margin: 10px">
  182. <el-tab-pane
  183. v-for="(column, index) in tabColumns"
  184. :key="index"
  185. :name="column.key"
  186. :label="column.title"
  187. lazy
  188. >
  189. <el-table :size="size" :data="params[column.key]">
  190. <el-table-column
  191. v-for="(cColumn, cIndex) in column.tableColumns"
  192. :key="cIndex"
  193. :prop="cColumn.key"
  194. :label="cColumn.title"
  195. :width="cColumn.width"
  196. >
  197. <template slot-scope="scope">
  198. <dict-tag
  199. v-if="cColumn.inputType === 'Select'"
  200. :size="size"
  201. :value="scope.row[cColumn.key]"
  202. :options="dict.type[cColumn.referName]"
  203. />
  204. <span v-else>{{ scope.row[cColumn.key] }}</span>
  205. </template>
  206. </el-table-column>
  207. </el-table>
  208. </el-tab-pane>
  209. </el-tabs>
  210. </el-drawer>
  211. </template>