index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <!-- 批量新增 -->
  2. <script>
  3. import useColumns from "../add/column";
  4. import {addChangeList, getMaterialDetails, getChangeDetails, editChangeList} from '@/api/changeApply/basic';
  5. export default {
  6. name: "SeeChangeOrders",
  7. props: {
  8. dict: {
  9. type: Object,
  10. },
  11. },
  12. components: {
  13. AmendantRecord: () => import("../amendantRecord/index.vue"),
  14. ElSuperForm: () => import("@/components/super-form/index.vue"),
  15. ElSuperTable: () => import("@/components/super-table/index.vue"),
  16. ElPopoverSelectV2: () => import("@/components/popover-select-v2/index.vue"),
  17. ElPopoverTreeSelect: () =>
  18. import("@/components/popover-tree-select/index.vue"),
  19. },
  20. data() {
  21. const {
  22. TabColumns,
  23. TableColumns,
  24. TabColumns: [
  25. {
  26. item: { key: tabName },
  27. },
  28. ],
  29. } = useColumns();
  30. const rules = this.$init.rules([...TabColumns, ...TableColumns]);
  31. const params = this.$init.params([...TabColumns, ...TableColumns]);
  32. let tabColumns = _.cloneDeep(TabColumns);
  33. tabColumns = tabColumns.map(item =>(
  34. {...item,
  35. TableColumns: [...item.TableColumns.map(column =>({
  36. item:{...column.item,disabled:true},
  37. attr:{
  38. ...column.attr,
  39. disabled:true
  40. }
  41. }))]
  42. }
  43. )
  44. )
  45. console.log(tabColumns,'tabColumns');
  46. return {
  47. width: "100%",
  48. visible: false,
  49. loading:false,
  50. title:'查看',
  51. rules,
  52. params,
  53. tabName: tabName,
  54. TabColumns: tabColumns,
  55. TableColumns: TableColumns,
  56. };
  57. },
  58. computed: {
  59. materialInfo:{
  60. get(){
  61. const { materialBasic } = this.params;
  62. this.params.materialBasic = materialBasic.map((item, index) => ({
  63. ...item,
  64. $index: index,
  65. }));
  66. return {
  67. materialBasic: this.params.materialBasic.filter(
  68. ({ delFlag }) => delFlag !== "2"
  69. ),
  70. }
  71. },
  72. set(){},
  73. }
  74. },
  75. watch: {
  76. },
  77. methods: {
  78. setVisible(prop){
  79. this.visible = prop;
  80. },
  81. beforeOpen(){
  82. },
  83. //
  84. async fetchItem(prop) {
  85. try {
  86. // try
  87. this.loading = true;
  88. let { code, data } = await getChangeDetails(prop.id);
  89. if(code == 200){
  90. this.params = data;
  91. }
  92. } catch (err) {
  93. // catch
  94. console.error(err);
  95. } finally {
  96. // finally
  97. this.loading = false;
  98. }
  99. },
  100. //
  101. async hide() {
  102. const {
  103. TabColumns,
  104. TableColumns,
  105. TabColumns: [
  106. {
  107. item: { key: tabName },
  108. },
  109. ],
  110. } = useColumns();
  111. this.visible = false;
  112. this.tabName = tabName;
  113. this.$emit('success');
  114. this.params = this.$init.params([...TabColumns, ...TableColumns]);
  115. },
  116. async handleSubmit(){
  117. this.params = {...this.params,status:'1'};
  118. console.log(this.params,'this.params');
  119. try {
  120. this.loading = true;
  121. const {code,msg} = await addChangeList(this.params);
  122. if(code == 200){
  123. this.hide();
  124. this.$notify.success({
  125. message: msg,
  126. });
  127. }
  128. } catch (error) {}
  129. finally{
  130. this.loading = false;
  131. }
  132. },
  133. handleSubmitValidate(prop,cb){
  134. this.$refs[prop].$refs[prop].validate(async (valid) => {
  135. if (valid) {
  136. try {
  137. this.loading = true;
  138. await cb();
  139. } catch (err) {
  140. // catch
  141. console.error(err);
  142. } finally {
  143. // finally
  144. this.loading = false;
  145. }
  146. } else {
  147. return false;
  148. }
  149. });
  150. },
  151. },
  152. created() {
  153. },
  154. mounted() {},
  155. destroyed() {},
  156. };
  157. </script>
  158. <template>
  159. <el-drawer
  160. v-bind="$attrs"
  161. v-on="$listeners"
  162. :size="width"
  163. :visible.sync="visible"
  164. destroy-on-close
  165. :show-close="false"
  166. @close="hide"
  167. @open="beforeOpen"
  168. v-loading="loading"
  169. >
  170. <div
  171. slot="title"
  172. style="display: flex;
  173. justify-content: space-between;
  174. align-items: center;"
  175. >
  176. <h3>{{title}}</h3>
  177. <div>
  178. <el-button
  179. v-if="params.status === '0' || params.status === '3'"
  180. type="primary"
  181. :size="$attrs.size"
  182. :loading="loading"
  183. @click="handleSubmit"
  184. >
  185. 提 交
  186. </el-button>
  187. <el-button :size="$attrs.size" :loading="loading" @click="hide"
  188. >取 消</el-button>
  189. </div>
  190. </div>
  191. <el-super-form
  192. v-model="params"
  193. :dict="dict"
  194. :rules="rules"
  195. :size="$attrs.size"
  196. :columns="TableColumns"
  197. ref="superForm"
  198. label-width="auto"
  199. label-position="right"
  200. style="padding: 20px"
  201. >
  202. <template slot="puOrgName" slot-scope="scope">
  203. <component
  204. v-bind="scope.attr"
  205. v-model="scope.row[scope.item.key]"
  206. :size="$attrs.size"
  207. :source.sync="scope.row"
  208. @change="changePuOrgName({ ...scope, select: $event })"
  209. >
  210. </component
  211. ></template>
  212. </el-super-form>
  213. <el-tabs v-model="tabName" style="padding: 0 20px 20px">
  214. <el-tab-pane
  215. v-for="({ item, TableColumns: columns }, index) in TabColumns"
  216. :key="index"
  217. :label="item.title"
  218. :name="item.key"
  219. lazy
  220. >
  221. <el-super-table
  222. v-model="materialInfo[item.key]"
  223. :dict="dict"
  224. :ref="tabName"
  225. :columns="columns"
  226. :size="$attrs.size"
  227. >
  228. <template slot="materialName" slot-scope="scope">
  229. <component
  230. v-bind="scope.attr"
  231. v-model="scope.row[scope.item.key]"
  232. :size="$attrs.size"
  233. :source.sync="scope.row"
  234. @change="changeMaterialName(scope)"
  235. >
  236. </component>
  237. </template>
  238. <el-table-column fixed="right" label="操作" width="120" align="center">
  239. <template slot-scope="scope">
  240. <AmendantRecord
  241. v-if=" tabName ==='materialBasic' "
  242. v-model="scope.row"
  243. ></AmendantRecord>
  244. </template>
  245. </el-table-column>
  246. </el-super-table>
  247. </el-tab-pane>
  248. </el-tabs>
  249. </el-drawer>
  250. </template>
  251. <style scoped>
  252. ::v-deep .el-table__row.is-hidden {
  253. display: none;
  254. }
  255. </style>