index.vue 7.5 KB

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