index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <el-card
  3. v-loading="loading"
  4. style="width: calc(100% - 24px); height: 100%; margin: 10px;padding: 10px;"
  5. :body-style="{ padding: 0 }"
  6. >
  7. <AddChangeOrders
  8. ref="addChangeOrders"
  9. :size="size"
  10. :dict="dict"
  11. :add-type="optionType"
  12. @success="useReset"
  13. ></AddChangeOrders>
  14. <SeeChangeOrders
  15. ref="seeChangeOrders"
  16. :size="size"
  17. :dict="dict"
  18. @success="useReset"
  19. ></SeeChangeOrders>
  20. <div>
  21. <el-super-search
  22. v-model="params"
  23. :size="size"
  24. :dict="dict"
  25. :columns="SearchColumns"
  26. @reset="useReset"
  27. @row-dblclick="useSee"
  28. @submit="useQuery(params, page)"
  29. ></el-super-search>
  30. <el-row
  31. :gutter="10"
  32. class="mb10"
  33. type="flex"
  34. justify="end"
  35. style="margin-top: 20px;"
  36. >
  37. <el-col :span="1.5">
  38. <el-button type="primary" size="mini" @click="newAdd">新增</el-button>
  39. <!-- <BatchImport></BatchImport> -->
  40. </el-col>
  41. </el-row>
  42. <div style="height: 600px; display:flex;">
  43. <el-super-table
  44. v-model="tableList"
  45. :dict="dict"
  46. :columns="TableColumns"
  47. :size="size"
  48. pagination
  49. :page="page"
  50. @pagination="useQuery(params, page)"
  51. @row-dblclick="useSee"
  52. >
  53. <el-table-column fixed="right" label="操作" width="150" align="center">
  54. <template slot-scope="scope">
  55. <el-button type="text" size="small" @click="useSee(scope.row)">查看</el-button>
  56. <el-button @click="handleEdit(scope.row)" v-if="scope.row.status == 0 || scope.row.status == 3" type="text" size="small">编辑</el-button>
  57. <el-button type="text" size="small" @click="deleteRow(scope.row)" v-if="scope.row.status == 0 || scope.row.status == 3">删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-super-table>
  61. </div>
  62. </div>
  63. </el-card>
  64. </template>
  65. <script>
  66. import { dicts } from "./dicts";
  67. import { getChangeList , deleteChangeList} from '@/api/changeApply/basic';
  68. import useColumns from './columns';
  69. export default {
  70. name: 'changeApply',
  71. dicts:dicts,
  72. components: {
  73. AddChangeOrders:() => import('./add/index.vue'),
  74. SeeChangeOrders:() => import('./see/index.vue'),
  75. BatchImport:() => import('./batchImport/index.vue'),
  76. ElSuperTable: () => import("@/components/super-table/index.vue"),
  77. ElSuperSearch: () => import("@/components/super-search/index.vue"),
  78. },
  79. data(){
  80. const {TableColumns,SearchColumns} = useColumns();
  81. const params = this.$init.params(SearchColumns);
  82. return {
  83. loading:false,
  84. size:'mini',
  85. tableList: [],
  86. TableColumns:TableColumns,
  87. page: { pageNum: 1, pageSize: 10, total: 0 },
  88. params:params,
  89. SearchColumns:SearchColumns,
  90. optionType:'add',
  91. }
  92. },
  93. methods:{
  94. useReset(){
  95. this.page.pageNum = 1;
  96. this.page.pageSize = 10;
  97. this.params = this.$init.params(this.SearchColumns);
  98. this.useQuery(this.params, this.page);
  99. },
  100. //
  101. openAddChangeOrders(row) {
  102. const {setVisible,fetchItem} = this.$refs.addChangeOrders;
  103. setVisible(true);
  104. row && fetchItem(row);
  105. },
  106. async newAdd(){
  107. this.optionType = 'add';
  108. await this.openAddChangeOrders();
  109. },
  110. async handleEdit(row){
  111. this.optionType = 'edit';
  112. await this.openAddChangeOrders(row);
  113. },
  114. async useQuery(params,page) {
  115. try {
  116. this.loading = true;
  117. let {code,rows,total} = await getChangeList({...params,...page});
  118. if (code === 200) {
  119. this.tableList = rows
  120. this.page.total = total;
  121. }
  122. } catch (error) {
  123. }finally{
  124. this.loading = false;
  125. }
  126. },
  127. async useSee(row){
  128. const {setVisible,fetchItem} = this.$refs.seeChangeOrders;
  129. await setVisible(true);
  130. await fetchItem(row);
  131. },
  132. deleteRow(row){
  133. this.$confirm('是否删除此条数据?', '提示', {
  134. confirmButtonText: '确定',
  135. cancelButtonText: '取消',
  136. type: 'warning'
  137. }).then(async() => {
  138. try {
  139. let {code,msg} = await deleteChangeList({id: row.id});
  140. if(code == 200){
  141. this.$notify.success({
  142. // title: '成功',
  143. message: msg,
  144. });
  145. await this.useQuery(this.params, this.page);
  146. }
  147. } catch (error) {}
  148. })
  149. },
  150. },
  151. created(){
  152. this.useQuery(this.params, this.page);
  153. },
  154. }
  155. </script>