index.vue 7.9 KB

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