list.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. ref="crud"
  5. :data="data"
  6. :option="optionTable"
  7. :page.sync="page"
  8. :table-loading="loading"
  9. @row-del="rowDel"
  10. @row-update="rowUpdate"
  11. @row-save="rowSave"
  12. @size-change="sizeChange"
  13. @current-change="currentChange"
  14. @search-change="searchChange"
  15. @refresh-change="refreshChange"
  16. @on-load="getList"
  17. @saveColumn="saveColumn"
  18. >
  19. <template slot="menuLeft">
  20. <el-button type="primary"
  21. size="small"
  22. icon="el-icon-plus"
  23. @click="addMainItems">新 单
  24. </el-button>
  25. <el-button icon="el-icon-printer"
  26. size="small"
  27. type="primary"
  28. @click.stop="openReport()"
  29. >报 表
  30. </el-button>
  31. </template>
  32. <template slot-scope="scope" slot="menu">
  33. <el-button
  34. type="text"
  35. icon="el-icon-edit"
  36. size="small"
  37. @click.stop="editOpen(scope.row, scope.index)"
  38. >编辑
  39. </el-button>
  40. <el-button
  41. type="text"
  42. icon="el-icon-delete"
  43. size="small"
  44. @click.stop="rowDel(scope.row, scope.index)"
  45. >删除
  46. </el-button>
  47. </template>
  48. <report-dialog
  49. :switchDialog="switchDialog"
  50. @onClose="onClose()"
  51. ></report-dialog>
  52. </avue-crud>
  53. </basic-container>
  54. </template>
  55. <script>
  56. import option from "./configuration/mainList.json";
  57. import { getList,deleteMain } from "@/api/workManagement/mainProject";
  58. import reportDialog from "@/components/report-dialog/main";
  59. export default {
  60. data() {
  61. return {
  62. switchDialog:false,
  63. loading: false,
  64. data: [],
  65. optionTable: option,
  66. page: {
  67. currentPage: 1,
  68. total: 0,
  69. pageSize: 10
  70. }
  71. };
  72. },
  73. created() {
  74. },
  75. mounted() {
  76. option.height = window.innerHeight - 380 ;
  77. },
  78. components: {
  79. reportDialog
  80. },
  81. methods: {
  82. //打印
  83. openReport() {
  84. this.switchDialog =! this.switchDialog;
  85. },
  86. //关闭打印
  87. onClose(val) {
  88. this.switchDialog = val;
  89. },
  90. //flag:0 判断是主营项目还是结算
  91. getList(page,params = { flag : 0 }) {
  92. this.loading = true;
  93. getList(page.currentPage, page.pageSize,params).then(res =>{
  94. this.data = res.data.data.records
  95. this.page.total = res.data.data.total
  96. this.loading = false
  97. })
  98. },
  99. //新单打开
  100. addMainItems(){
  101. this.$router.push({
  102. path: "/mainItems_detailsPage",
  103. query: {id: ''},
  104. });
  105. },
  106. //编辑打开
  107. editOpen(row, index){
  108. console.log(row)
  109. this.$router.push({
  110. path: "/mainItems_detailsPage",
  111. query: {id:row.id},
  112. });
  113. },
  114. searchChange(params, done) {
  115. this.getList(this.page, params = { flag : 0 });
  116. done();
  117. },
  118. refreshChange(page,params) {
  119. console.log(page,params)
  120. this.getList(page,params);
  121. },
  122. //删除列表后面的删除按钮触发触发(row, index, done)
  123. rowDel(row, index, done) {
  124. if(row.allowDelete){
  125. this.$confirm("确定将选择数据删除?", {
  126. confirmButtonText: "确定",
  127. cancelButtonText: "取消",
  128. type: "warning"
  129. }).then(() => {
  130. deleteMain(row.id).then(res =>{
  131. this.$message({
  132. type: "success",
  133. message: "操作成功!"
  134. });
  135. })
  136. // 数据回调进行刷新
  137. done(row);
  138. });
  139. }else{
  140. this.$message({
  141. type: "warning",
  142. message: "当前项目存在已请核任务 不能删除!"
  143. });
  144. }
  145. },
  146. //修改时的修改按钮点击触发
  147. rowUpdate(row, index, done, loading) {
  148. setTimeout(() => {
  149. this.$message.success("修改成功");
  150. loading();
  151. done();
  152. }, 1000);
  153. },
  154. //新增修改时保存触发
  155. rowSave(row, done, loading) {
  156. setTimeout(() => {
  157. this.$message.success("保存成功");
  158. loading();
  159. done();
  160. }, 1000);
  161. },
  162. saveColumn(row, column) {
  163. console.log(row, column);
  164. },
  165. //打开详情页
  166. beforeOpenPage(row, index) {
  167. this.$router.push({
  168. path: "/mainItems_detailsPage",
  169. query: { id: JSON.stringify(row.prop1) }
  170. });
  171. }
  172. }
  173. };
  174. </script>
  175. <style></style>