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