index.vue 9.4 KB

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