index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div>
  3. <basic-container v-if="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. :summary-method="summaryMethod"
  19. >
  20. <template slot="menuLeft">
  21. <el-button
  22. type="primary"
  23. icon="el-icon-plus"
  24. size="small"
  25. @click.stop="newAdd()"
  26. >新单</el-button
  27. >
  28. <el-button type="success" size="small" disabled>复制新单</el-button>
  29. <el-button type="info" size="small">报表</el-button>
  30. </template>
  31. <template slot="corpIdSearch">
  32. <select-component
  33. v-model="search.corpId"
  34. :configuration="configuration"
  35. ></select-component>
  36. </template>
  37. <template slot-scope="scope" slot="menu">
  38. <el-button
  39. type="text"
  40. icon="el-icon-view"
  41. size="small"
  42. @click.stop="beforeOpenPage(scope.row, 1)"
  43. >查看
  44. </el-button>
  45. <el-button
  46. type="text"
  47. icon="el-icon-edit"
  48. size="small"
  49. @click.stop="editOpen(scope.row, 2)"
  50. >编辑
  51. </el-button>
  52. <el-button
  53. type="text"
  54. icon="el-icon-delete"
  55. size="small"
  56. @click.stop="rowDel(scope.row, scope.index)"
  57. >删除
  58. </el-button>
  59. </template>
  60. </avue-crud>
  61. </basic-container>
  62. <detail-page @goBack="goBack" :detailData="detailData" v-else></detail-page>
  63. </div>
  64. </template>
  65. <script>
  66. import option from "./config/mainList.json";
  67. import { getList, remove } from "@/api/exportTrade/receipt";
  68. import detailPage from "./detailsPage.vue";
  69. import { micrometerFormat } from "@/util/validate";
  70. import _ from "lodash";
  71. export default {
  72. name: "customerInformation",
  73. data() {
  74. return {
  75. configuration: {
  76. multipleChoices: false,
  77. multiple: false,
  78. collapseTags: false,
  79. placeholder: "请点击右边按钮选择",
  80. dicData: []
  81. },
  82. search: {},
  83. form: {},
  84. option: {},
  85. parentId: 0,
  86. dataList: [],
  87. page: {
  88. pageSize: 10,
  89. currentPage: 1,
  90. total: 0
  91. },
  92. show: true,
  93. detailData: {},
  94. loading: false
  95. };
  96. },
  97. components: { detailPage },
  98. async created() {
  99. this.option = await this.getColumnData(this.getColumnName(6), option);
  100. if (this.$route.query.pageType == "Generate") {
  101. this.newAdd();
  102. }
  103. let _this = this;
  104. this.option.column.forEach(e => {
  105. if (e.prop == "exchangeRate") {
  106. e.formatter = function(row) {
  107. return _this.textFormat(
  108. Number(row.exchangeRate ? row.exchangeRate : 0) / 100,
  109. "0.00%"
  110. );
  111. };
  112. }
  113. if (e.prop == "creditAmount") {
  114. e.formatter = function(row) {
  115. return _this.textFormat(
  116. Number(row.creditAmount ? row.creditAmount : 0),
  117. "#,##0.00"
  118. );
  119. };
  120. }
  121. });
  122. },
  123. activated() {
  124. //当页面已打开并无法重新渲染时,用activated重新激活keepalive组件
  125. setTimeout(() => {
  126. if (this.$route.query.pageType == "Generate" && this.show) {
  127. this.newAdd();
  128. }
  129. }, 100);
  130. },
  131. methods: {
  132. //删除列表后面的删除按钮触发触发(row, index, done)
  133. rowDel(row, index, done) {
  134. this.$confirm("确定删除数据?", {
  135. confirmButtonText: "确定",
  136. cancelButtonText: "取消",
  137. type: "warning"
  138. }).then(() => {
  139. remove(row.id);
  140. this.$message({
  141. type: "success",
  142. message: "删除成功!"
  143. });
  144. this.page.currentPage = 1;
  145. this.onLoad(this.page);
  146. });
  147. },
  148. //查看跳转页面
  149. beforeOpenPage(row, status) {
  150. this.detailData = {
  151. id: row.id,
  152. status: status
  153. };
  154. this.show = false;
  155. this.$store.commit("REC_IN_DETAIL");
  156. },
  157. editOpen(row, status) {
  158. this.detailData = {
  159. id: row.id,
  160. status: status
  161. };
  162. this.show = false;
  163. this.$store.commit("REC_IN_DETAIL");
  164. },
  165. //点击搜索按钮触发
  166. searchChange(params, done) {
  167. this.page.currentPage = 1;
  168. this.onLoad(this.page, params);
  169. done();
  170. },
  171. currentChange(val) {
  172. this.page.currentPage = val;
  173. },
  174. sizeChange(val) {
  175. this.page.currentPage = 1;
  176. this.page.pageSize = val;
  177. },
  178. onLoad(page, params) {
  179. getList(page.currentPage, page.pageSize, params)
  180. .then(res => {
  181. this.dataList = res.data.data.records ? res.data.data.records : [];
  182. this.page.total = res.data.data.total;
  183. if (this.page.total) {
  184. this.option.height = window.innerHeight - 435;
  185. } else {
  186. this.option.height = window.innerHeight - 360;
  187. }
  188. })
  189. .finally(() => {
  190. this.loading = false;
  191. });
  192. },
  193. refreshChange() {
  194. this.onLoad(this.page, this.search);
  195. },
  196. newAdd() {
  197. this.show = false;
  198. this.$store.commit("REC_IN_DETAIL");
  199. },
  200. goBack() {
  201. this.detailData = this.$options.data().detailData;
  202. if (this.$route.query.pageType == "Generate") {
  203. this.$router.$avueRouter.closeTag();
  204. this.$router.push({
  205. path: "/exportTrade/receipt/index"
  206. });
  207. }
  208. this.show = true;
  209. this.$store.commit("REC_OUT_DETAIL");
  210. },
  211. summaryMethod({ columns, data }) {
  212. const sums = [];
  213. if (columns.length > 0) {
  214. columns.forEach((item, index) => {
  215. sums[0] = "合计";
  216. if (
  217. item.property == "totalQuantity" ||
  218. item.property == "deliveryAmount" ||
  219. item.property == "totalCost"
  220. ) {
  221. let qtySum = 0;
  222. let instoreSum = 0;
  223. let totalSum = 0;
  224. data.forEach(e => {
  225. qtySum = _.add(qtySum, Number(e.totalQuantity));
  226. instoreSum = _.add(instoreSum, Number(e.deliveryAmount));
  227. totalSum = _.add(totalSum, Number(e.totalCost));
  228. });
  229. //数量总计
  230. if (item.property == "totalQuantity") {
  231. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  232. }
  233. //入库金额总计
  234. if (item.property == "deliveryAmount") {
  235. sums[index] = micrometerFormat(instoreSum);
  236. }
  237. //金额总计
  238. if (item.property == "totalCost") {
  239. sums[index] = micrometerFormat(totalSum);
  240. }
  241. }
  242. });
  243. }
  244. return sums;
  245. },
  246. async saveColumn() {
  247. const inSave = await this.saveColumnData(
  248. this.getColumnName(6),
  249. this.option
  250. );
  251. if (inSave) {
  252. this.$message.success("保存成功");
  253. //关闭窗口
  254. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  255. }
  256. }
  257. }
  258. };
  259. </script>
  260. <style scoped>
  261. ::v-deep .select-component {
  262. display: flex;
  263. }
  264. .page-crad ::v-deep .basic-container__card {
  265. height: 86.5vh;
  266. }
  267. </style>