index.vue 11 KB

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