index.vue 8.9 KB

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