index.vue 10 KB

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