index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <script>
  2. import { Columns, TabColumns } from "../add/column";
  3. import { item, itemTableList } from "@/api/business/purchase/contract";
  4. import { initColumns, initDicts, initRules, initParams } from "@/utils/init";
  5. const NewColumns = initColumns(Columns, { disabled: true, readonly: true });
  6. const NewTabColumns = TabColumns.map((element) => ({
  7. ...element,
  8. tableColumns: initColumns(element.tableColumns, {
  9. disabled: true,
  10. readonly: true,
  11. }),
  12. }));
  13. export default {
  14. name: "SeeDrawer",
  15. dicts: initDicts(NewColumns),
  16. data() {
  17. return {
  18. visible: false,
  19. loading: false,
  20. columns: NewColumns,
  21. rules: initRules(NewColumns),
  22. params: {
  23. ...initParams(NewColumns),
  24. contractItemList: [],
  25. contractClauseList: [],
  26. contractExpenseList: [],
  27. contractAgreementList: [],
  28. contractApplyOrgList: [],
  29. },
  30. tabColumns: NewTabColumns,
  31. tabName: "contractItemList",
  32. };
  33. },
  34. computed: {},
  35. watch: {
  36. "params.contractType": function (newProp) {
  37. this.tabColumns = NewTabColumns.filter((element) =>
  38. newProp === "1" ? element.key !== "contractItemList" : element
  39. );
  40. this.tabName = this.tabColumns[0].key;
  41. },
  42. tabName: function (newProp) {
  43. const { id } = this.params;
  44. this.fetchTable(id, newProp);
  45. },
  46. },
  47. methods: {
  48. setVisible(prop) {
  49. this.visible = prop;
  50. },
  51. // 查询详细
  52. async fetchItem(prop) {
  53. try {
  54. this.loading = true;
  55. const { code, msg, data } = await item(prop);
  56. if (code === 200) {
  57. this.params = data;
  58. this.$notify.success({ title: msg });
  59. } else {
  60. this.$notify.warning({ title: msg });
  61. }
  62. } catch (err) {
  63. //
  64. } finally {
  65. this.loading = false;
  66. }
  67. },
  68. // 查询详情关联TABLE
  69. async fetchTable(prop, name) {
  70. try {
  71. this.loading = true;
  72. const { code, msg, rows } = await itemTableList({ id: prop }, name);
  73. if (code === 200) {
  74. this.params[name] = rows;
  75. this.$notify.success({ title: msg });
  76. } else {
  77. this.$notify.warning({ title: msg });
  78. }
  79. } catch (err) {
  80. //
  81. } finally {
  82. this.loading = false;
  83. }
  84. },
  85. // 取消操作
  86. handleCancel() {
  87. this.setVisible(false);
  88. this.params = initParams(Columns);
  89. },
  90. // 编辑操作
  91. handleOpenEditDrawer(prop) {
  92. this.setVisible(false);
  93. this.$parent.$parent.handleOpenEditDrawer(prop);
  94. },
  95. },
  96. created() {},
  97. mounted() {},
  98. destroyed() {},
  99. };
  100. </script>
  101. <template>
  102. <el-drawer
  103. direction="btt"
  104. size="100%"
  105. :with-header="false"
  106. :visible.sync="visible"
  107. destroy-on-close
  108. >
  109. <el-form
  110. v-loading="loading"
  111. size="mini"
  112. label-position="right"
  113. label-width="135px"
  114. :model="params"
  115. :rules="rules"
  116. >
  117. <el-card
  118. :body-style="{
  119. padding: '20px',
  120. display: 'flex',
  121. 'flex-wrap': 'wrap',
  122. }"
  123. style="margin: 10px"
  124. >
  125. <div
  126. slot="header"
  127. style="
  128. display: flex;
  129. justify-content: space-between;
  130. align-items: center;
  131. "
  132. >
  133. <h3>查看</h3>
  134. <div style="text-align: right">
  135. <el-button size="mini" @click="handleOpenEditDrawer(params)"
  136. >编 辑</el-button
  137. >
  138. <el-button size="mini" @click="handleCancel">取 消</el-button>
  139. </div>
  140. </div>
  141. <el-row>
  142. <el-col
  143. v-for="(column, index) in columns"
  144. :key="index"
  145. :span="column.span || 6"
  146. >
  147. <el-form-item :prop="column.key" :label="column.title">
  148. <el-input
  149. v-if="column.type === 'Textarea'"
  150. v-model="params[column.key]"
  151. type="textarea"
  152. :placeholder="column.placeholder"
  153. :clearable="column.clearable"
  154. :disabled="column.disabled"
  155. :readonly="column.readonly"
  156. style="width: 100%"
  157. ></el-input>
  158. <el-input-number
  159. v-else-if="column.type === 'InputNumber'"
  160. v-model="params[column.key]"
  161. :controls-position="column.config.controlsPosition"
  162. :placeholder="column.placeholder"
  163. :clearable="column.clearable"
  164. :disabled="column.disabled"
  165. :readonly="column.readonly"
  166. style="width: 100%"
  167. ></el-input-number>
  168. <el-select
  169. v-else-if="column.type === 'Select'"
  170. v-model="params[column.key]"
  171. :placeholder="column.placeholder"
  172. :clearable="column.clearable"
  173. :disabled="column.disabled"
  174. :readonly="column.readonly"
  175. style="width: 100%"
  176. >
  177. <el-option
  178. v-for="item in dict.type[column.config.optionsName]"
  179. :key="item.value"
  180. :label="item.label"
  181. :value="item.value"
  182. >
  183. </el-option>
  184. </el-select>
  185. <el-date-picker
  186. v-else-if="column.type === 'DatePicker'"
  187. v-model="params[column.key]"
  188. :type="column.config.type"
  189. :placeholder="column.placeholder"
  190. :clearable="column.clearable"
  191. :disabled="column.disabled"
  192. :readonly="column.readonly"
  193. :picker-options="column.pickerOptions"
  194. style="width: 100%"
  195. >
  196. </el-date-picker>
  197. <el-upload
  198. v-else-if="column.type === 'Upload'"
  199. :file-list="params[column.key]"
  200. :disabled="column.disabled"
  201. :readonly="column.readonly"
  202. drag
  203. action="https://jsonplaceholder.typicode.com/posts/"
  204. multiple
  205. >
  206. <i class="el-icon-upload"></i>
  207. <div class="el-upload__text">
  208. 将文件拖到此处,或<em>点击上传</em>
  209. </div>
  210. <div class="el-upload__tip" slot="tip">
  211. 只能上传jpg/png文件,且不超过500kb
  212. </div>
  213. </el-upload>
  214. <el-input
  215. v-else
  216. v-model="params[column.key]"
  217. :placeholder="column.placeholder"
  218. :clearable="column.clearable"
  219. :disabled="column.disabled"
  220. :readonly="column.readonly"
  221. style="width: 100%"
  222. ></el-input>
  223. </el-form-item>
  224. </el-col>
  225. </el-row>
  226. </el-card>
  227. <el-card
  228. :body-style="{
  229. padding: '20px',
  230. display: 'flex',
  231. 'flex-wrap': 'wrap',
  232. position: 'relative',
  233. }"
  234. style="margin: 10px"
  235. >
  236. <el-tabs v-model="tabName" style="width: 100%">
  237. <el-tab-pane
  238. v-for="(column, index) in tabColumns"
  239. :key="index"
  240. :label="column.title"
  241. :name="column.key"
  242. >
  243. <el-table :data="params[column.key]" style="width: 100%">
  244. <el-table-column
  245. v-for="(cColumn, cIndex) in column.tableColumns"
  246. :key="cIndex"
  247. :prop="cColumn.key"
  248. :label="cColumn.title"
  249. :width="cColumn.width"
  250. >
  251. <template slot-scope="scope">
  252. <el-tag v-if="cColumn.key === 'index'">
  253. {{ scope.$index + 1 }}
  254. </el-tag>
  255. <el-input
  256. v-if="cColumn.type === 'Input'"
  257. v-model="scope.row[cColumn.key]"
  258. :placeholder="cColumn.placeholder"
  259. :clearable="cColumn.clearable"
  260. :disabled="cColumn.disabled"
  261. size="mini"
  262. style="width: 100%"
  263. ></el-input>
  264. <el-input-number
  265. v-if="cColumn.type === 'InputNumber'"
  266. v-model="scope.row[cColumn.key]"
  267. :controls-position="cColumn.config.controlsPosition"
  268. :placeholder="cColumn.placeholder"
  269. :clearable="cColumn.clearable"
  270. :disabled="cColumn.disabled"
  271. size="mini"
  272. style="width: 100%"
  273. ></el-input-number>
  274. <el-input
  275. v-if="column.type === 'InputDialog'"
  276. v-model="params[column.key]"
  277. :placeholder="column.placeholder"
  278. :clearable="column.clearable"
  279. :disabled="column.disabled"
  280. :readonly="column.readonly"
  281. style="width: 100%; cursor: pointer"
  282. @click.native.stop="openAsyncInputDialog(column, params)"
  283. >
  284. <template #suffix>
  285. <el-icon class="el-icon-thumb"></el-icon>
  286. </template>
  287. </el-input>
  288. </template>
  289. </el-table-column>
  290. <!-- <el-table-column fixed="right" label="操作" width="120">
  291. <template slot-scope="scope">
  292. <el-button
  293. @click.native.prevent="
  294. delTableRow(params[tabName], scope.$index)
  295. "
  296. type="text"
  297. size="small"
  298. >
  299. 删行
  300. </el-button>
  301. </template>
  302. </el-table-column> -->
  303. </el-table>
  304. </el-tab-pane>
  305. </el-tabs>
  306. <!-- <el-row style="position: absolute; top: 20px; right: 20px">
  307. <el-button size="mini" @click="addTableRow(params[tabName])"
  308. >增行</el-button
  309. >
  310. </el-row> -->
  311. </el-card>
  312. </el-form>
  313. </el-drawer>
  314. </template>