index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud ref="crud" :option="option" :data="dataList" v-model="form" :page.sync="page"
  5. :search.sync="search" @search-change="searchChange" @current-change="currentChange"
  6. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading"
  7. @saveColumn="saveColumn" @resetColumn="resetColumn" :cell-style="cellStyle"
  8. @selection-change="selectionChange" @search-criteria-switch="searchCriteriaSwitch">
  9. <!-- <template slot="menuLeft">
  10. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="newAdd()">创建单据
  11. </el-button>
  12. </template> -->
  13. <template slot="stockTimeSearch">
  14. <el-date-picker v-model="search.stockTime" type="daterange" start-placeholder="开始日期"
  15. end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
  16. </el-date-picker>
  17. </template>
  18. <template slot="purchaserIdSearch">
  19. <crop-select v-model="search.purchaserId" corpType="KH" :refresh="false"></crop-select>
  20. </template>
  21. <template slot="corpIdSearch">
  22. <crop-select v-model="search.corpId" corpType="GYS" :refresh="false"></crop-select>
  23. </template>
  24. <template slot-scope="{ row,index}" slot="purchaserId">
  25. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 1)">{{ row.purchaser }}
  26. </span>
  27. </template>
  28. <template slot-scope="{ row,index}" slot="corpId">
  29. <span>{{ row.corpName }}
  30. </span>
  31. </template>
  32. </avue-crud>
  33. </basic-container>
  34. <detail-page ref="detail" @goBack="goBack" :detailData="detailData" v-if="!show"></detail-page>
  35. </div>
  36. </template>
  37. <script>
  38. import { getList, remove, getStoragetree } from "@/api/purchasingManagement/inStock";
  39. import option from "./config/mainList.json";
  40. import detailPage from "./detailsPage";
  41. import _ from "lodash";
  42. export default {
  43. name: "instock",
  44. data() {
  45. return {
  46. search: {},
  47. form: {},
  48. option: {},
  49. dataList: [],
  50. page: {
  51. pageSize: 20,
  52. currentPage: 1,
  53. total: 0,
  54. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  55. },
  56. show: true,
  57. detailData: {},
  58. loading: false,
  59. searchShow: true,
  60. selectionList: [],
  61. };
  62. },
  63. components: { detailPage },
  64. async created() {
  65. this.option = await this.getColumnData(this.getColumnName(190), option);
  66. this.option.height = window.innerHeight - 210;
  67. this.getAllWorkDicts()
  68. },
  69. activated() {
  70. setTimeout(() => {
  71. if (this.$route.query.generateId && this.show) {
  72. // this.detailData.id = this.$route.query.generateId
  73. this.show = false;
  74. }
  75. if (this.$route.query.check && this.show) {
  76. this.editOpen({ id: this.$route.query.check.srcBillId }, 1)
  77. this.show = false;
  78. }
  79. }, 100);
  80. },
  81. methods: {
  82. getAllWorkDicts() {
  83. this.getWorkDicts("approval_status").then(res => {
  84. this.findObject(this.option.column, "status").dicData =
  85. res.data.data;
  86. });
  87. this.getWorkDicts("CMY_business_type").then(res => {
  88. this.findObject(this.option.column, "businessType").dicData =
  89. res.data.data;
  90. });
  91. getStoragetree().then(res => {
  92. this.findObject(this.option.column, "storageId").dicData =
  93. res.data.data;
  94. })
  95. },
  96. searchCriteriaSwitch(type) {
  97. if (type) {
  98. this.option.height = this.option.height - 191;
  99. } else {
  100. this.option.height = this.option.height + 191;
  101. }
  102. this.$refs.crud.getTableHeight();
  103. },
  104. cellStyle() {
  105. return "padding:0;height:40px;";
  106. },
  107. rowDel(row, index, done) {
  108. this.$confirm("确定删除数据?", {
  109. confirmButtonText: "确定",
  110. cancelButtonText: "取消",
  111. type: "warning"
  112. }).then(() => {
  113. remove({ id: row.id }).then(res => {
  114. this.$message({
  115. type: "success",
  116. message: "删除成功!"
  117. });
  118. })
  119. .finally(() => {
  120. this.onLoad(this.page, this.search);
  121. });
  122. });
  123. },
  124. selectionChange(list) {
  125. this.selectionList = list;
  126. },
  127. editOpen(row, status) {
  128. this.detailData = {
  129. id: row.id,
  130. status: status
  131. };
  132. this.show = false;
  133. },
  134. //点击搜索按钮触发
  135. searchChange(params, done) {
  136. this.page.currentPage = 1;
  137. this.onLoad(this.page, params);
  138. done();
  139. },
  140. currentChange(val) {
  141. this.page.currentPage = val;
  142. },
  143. sizeChange(val) {
  144. this.page.currentPage = 1;
  145. this.page.pageSize = val;
  146. },
  147. onLoad(page, params) {
  148. if (this.search.stockTime && this.search.stockTime.length > 0) {
  149. params = {
  150. ...params,
  151. createStartTime: this.search.stockTime[0] + ' ' + "00:00:00",
  152. createEndTime: this.search.stockTime[1] + ' ' + "23:59:59"
  153. };
  154. }
  155. let data = this.deepClone(Object.assign({}, params, this.search));
  156. delete data.stockTime;
  157. data.billType = "CK"
  158. this.loading = true;
  159. getList(page.currentPage, page.pageSize, data)
  160. .then(res => {
  161. this.dataList = res.data.data.records ? res.data.data.records : [];
  162. this.page.total = res.data.data.total;
  163. })
  164. .finally(() => {
  165. this.loading = false;
  166. });
  167. },
  168. refreshChange() {
  169. this.onLoad(this.page, this.search);
  170. },
  171. newAdd() {
  172. this.show = false;
  173. },
  174. goBack() {
  175. if (this.$route.query.id) {
  176. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  177. this.$router.push({
  178. path: "/purchasingManagement/inStock/index"
  179. });
  180. }
  181. this.detailData = this.$options.data().detailData;
  182. this.show = true;
  183. this.onLoad(this.page, this.search);
  184. },
  185. async saveColumn() {
  186. const inSave = await this.saveColumnData(
  187. this.getColumnName(190),
  188. this.option
  189. );
  190. if (inSave) {
  191. this.$nextTick(() => {
  192. this.$refs.crud.doLayout();
  193. });
  194. this.$message.success("保存成功");
  195. //关闭窗口
  196. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  197. }
  198. },
  199. async resetColumn() {
  200. this.option = option;
  201. const inSave = await this.delColumnData(this.getColumnName(190), this.option);
  202. if (inSave) {
  203. this.$nextTick(() => {
  204. this.$refs.crud.doLayout();
  205. });
  206. this.getAllWorkDicts()
  207. this.$message.success("重置成功");
  208. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  209. }
  210. }
  211. }
  212. };
  213. </script>
  214. <style scoped>
  215. ::v-deep .select-component {
  216. display: flex;
  217. }
  218. .page-crad ::v-deep .basic-container__card {
  219. height: 94.2vh;
  220. }
  221. .itemTable ::v-deep .el-table {
  222. width: 738px;
  223. }
  224. </style>