index.vue 8.9 KB

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