list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. ref="crud"
  5. :data="data"
  6. :option="optionTable"
  7. :page.sync="page"
  8. :search.sync="search"
  9. :table-loading="loading"
  10. :summary-method="summaryMethod"
  11. @row-del="rowDel"
  12. @row-update="rowUpdate"
  13. @row-save="rowSave"
  14. @search-change="searchChange"
  15. @refresh-change="refreshChange"
  16. @on-load="getList"
  17. @saveColumn="saveColumn"
  18. >
  19. <template slot="corpIdSearch">
  20. <select-component
  21. v-model="search.corpId"
  22. :configuration="configuration"
  23. ></select-component>
  24. </template>
  25. <template slot="menuLeft">
  26. <el-button type="primary"
  27. size="small"
  28. icon="el-icon-plus"
  29. @click="addMainItems">新 单
  30. </el-button>
  31. <el-button size="small"
  32. type="info"
  33. @click.stop="openReport()"
  34. >导出报表
  35. </el-button>
  36. </template>
  37. <template slot-scope="scope" slot="menu">
  38. <el-button
  39. type="text"
  40. icon="el-icon-edit"
  41. size="small"
  42. @click.stop="editOpen(scope.row, scope.index)"
  43. >编辑
  44. </el-button>
  45. <el-button
  46. type="text"
  47. icon="el-icon-delete"
  48. size="small"
  49. :disabled="!scope.row.allowDelete"
  50. @click.stop="rowDel(scope.row, scope.index)"
  51. >删除
  52. </el-button>
  53. </template>
  54. <report-dialog
  55. :switchDialog="switchDialog"
  56. @onClose="onClose()"
  57. ></report-dialog>
  58. </avue-crud>
  59. </basic-container>
  60. </template>
  61. <script>
  62. import option from "./configuration/mainList.json";
  63. import { getList,deleteMain } from "@/api/workManagement/mainProject";
  64. import reportDialog from "@/components/report-dialog/main";
  65. import { micrometerFormat } from "@/util/validate";
  66. import _ from "lodash";
  67. export default {
  68. data() {
  69. return {
  70. switchDialog:false,
  71. loading: false,
  72. data: [],
  73. search:{},
  74. configuration:{
  75. multipleChoices:false,
  76. multiple:false,
  77. disabled:false,
  78. searchShow:true,
  79. collapseTags:false,
  80. clearable:true,
  81. placeholder:'请点击右边按钮选择',
  82. dicData:[]
  83. },
  84. optionTable: option,
  85. page: {
  86. currentPage: 1,
  87. total: 0,
  88. pageSize: 10
  89. }
  90. };
  91. },
  92. created() {
  93. // option.height = window.innerHeight - 380 ;
  94. },
  95. mounted() {
  96. },
  97. components: {
  98. reportDialog
  99. },
  100. methods: {
  101. //打印
  102. openReport() {
  103. this.switchDialog =! this.switchDialog;
  104. },
  105. //关闭打印
  106. onClose(val) {
  107. this.switchDialog = val;
  108. },
  109. //flag:0 判断是主营项目还是结算
  110. getList(page,params = {}) {
  111. params.flag = 0;
  112. this.loading = true;
  113. if(params){
  114. if (params.createTime != undefined) { //发货
  115. params.createStartDate = params.createTime[0]+ " " + "00:00:00";
  116. params.createEndDate = params.createTime[1] + " " + "23:59:59";
  117. this.$delete(params,'createTime')
  118. }
  119. }
  120. getList(page.currentPage, page.pageSize,params).then(res =>{
  121. this.data = res.data.data.records
  122. this.page.total = res.data.data.total
  123. this.loading = false
  124. })
  125. },
  126. //新单打开
  127. addMainItems(){
  128. this.$router.push({
  129. path: "/mainItems_detailsPage",
  130. query: {id: ''},
  131. });
  132. },
  133. //编辑打开
  134. editOpen(row, index){
  135. console.log(row)
  136. this.$router.push({
  137. path: "/mainItems_detailsPage",
  138. query: {id:row.id},
  139. });
  140. },
  141. searchChange(params, done) {
  142. this.getList(this.page, params);
  143. done();
  144. },
  145. refreshChange(params) {
  146. this.getList(this.page,params);
  147. },
  148. //删除列表后面的删除按钮触发触发(row, index, done)
  149. rowDel(row, index, done) {
  150. if(row.allowDelete){
  151. this.$confirm("确定将选择数据删除?", {
  152. confirmButtonText: "确定",
  153. cancelButtonText: "取消",
  154. type: "warning"
  155. }).then(() => {
  156. deleteMain(row.id).then(res =>{
  157. this.$message({
  158. type: "success",
  159. message: "操作成功!"
  160. });
  161. })
  162. // 数据回调进行刷新
  163. this.getList(this.page);
  164. });
  165. }else{
  166. this.$message({
  167. type: "warning",
  168. message: "当前项目存在已请核任务 不能删除!"
  169. });
  170. }
  171. },
  172. //修改时的修改按钮点击触发
  173. rowUpdate(row, index, done, loading) {
  174. setTimeout(() => {
  175. this.$message.success("修改成功");
  176. loading();
  177. done();
  178. }, 1000);
  179. },
  180. //新增修改时保存触发
  181. rowSave(row, done, loading) {
  182. setTimeout(() => {
  183. this.$message.success("保存成功");
  184. loading();
  185. done();
  186. }, 1000);
  187. },
  188. saveColumn(row, column) {
  189. console.log(row, column);
  190. },
  191. summaryMethod({ columns, data }) {
  192. const sums = [];
  193. if (columns.length > 0) {
  194. columns.forEach((item, index) => {
  195. sums[0] = "合计";
  196. if (
  197. item.property == "debitAmount" ||
  198. item.property == "settlmentAmount"
  199. ) {
  200. let qtySum = 0;
  201. let instoreSum = 0;
  202. data.forEach(e => {
  203. qtySum = _.add(qtySum, Number(e.debitAmount));
  204. instoreSum = _.add(instoreSum, Number(e.settlmentAmount));
  205. });
  206. if (item.property == "debitAmount") {
  207. sums[index] = micrometerFormat(qtySum);
  208. }
  209. if (item.property == "settlmentAmount") {
  210. sums[index] = micrometerFormat(instoreSum);
  211. }
  212. }
  213. });
  214. }
  215. return sums;
  216. },
  217. //打开详情页
  218. beforeOpenPage(row, index) {
  219. this.$router.push({
  220. path: "/mainItems_detailsPage",
  221. query: { id: JSON.stringify(row.prop1) }
  222. });
  223. }
  224. }
  225. };
  226. </script>
  227. <style></style>