index.vue 9.5 KB

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