index.vue 10.0 KB

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