list.vue 4.4 KB

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