index.vue 11 KB

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