index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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. @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-scope="{ row,index}" slot="purchaserId">
  19. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 1)">{{ row.purchaser }}
  20. </span>
  21. </template>
  22. <template slot="purchaserIdSearch">
  23. <crop-select v-model="search.purchaserId" corpType="KH" :refresh="false"></crop-select>
  24. </template>
  25. <template slot="stockTimeSearch">
  26. <el-date-picker v-model="search.stockTime" type="daterange" start-placeholder="开始日期"
  27. end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
  28. </el-date-picker>
  29. </template>
  30. <template slot-scope="{ row,index}" slot="sysNo">
  31. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 1)">{{ row.sysNo }}
  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. <el-dialog title="盘点" :visible.sync="inStockVisible" width="70%" @close="close" append-to-body>
  41. <span>
  42. <avue-crud ref="crud2" v-model="form2" :data="itemData" :option="itemOption" :page.sync="page2"
  43. :search.sync="search2" @search-change="searchChange2" @current-change="currentChange2"
  44. @size-change="sizeChange2" @refresh-change="refreshChange2" @on-load="onLoad2"
  45. :table-loading="loading2" :cell-style="cellStyle" @selection-change="selectionChange"
  46. @search-criteria-switch="searchCriteriaSwitch2">
  47. <template slot="purchaserIdSearch">
  48. <crop-select v-model="search2.purchaserId" corpType="KH" :refresh="false"></crop-select>
  49. </template>
  50. <template slot="corpIdSearch">
  51. <crop-select v-model="search2.corpId" corpType="GYS" :refresh="false"></crop-select>
  52. </template>
  53. <template slot-scope="{ row,index}" slot="purchaserId">
  54. <span>{{ row.purchaser }}
  55. </span>
  56. </template>
  57. <template slot-scope="{ row,index}" slot="corpId">
  58. <span>{{ row.corpName }}
  59. </span>
  60. </template>
  61. <template slot="stockTimeSearch">
  62. <el-date-picker v-model="search2.stockTime" type="daterange" start-placeholder="开始日期"
  63. end-placeholder="结束日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd">
  64. </el-date-picker>
  65. </template>
  66. </avue-crud>
  67. </span>
  68. <span slot="footer" class="dialog-footer">
  69. <el-button @click="inStockVisible= false">取 消</el-button>
  70. <el-button type="primary" @click="generate">生 成</el-button>
  71. </span>
  72. </el-dialog>
  73. <detail-page @goBack="goBack" :detailData="detailData" v-if="!show"></detail-page>
  74. </div>
  75. </template>
  76. <script>
  77. import {getList, remove, getStoragetree} from "@/api/purchasingManagement/inStock";
  78. import option from "./config/mainList.json";
  79. import itemOption from "./config/mainList2.json";
  80. import detailPage from "./detailsPage";
  81. import _ from "lodash";
  82. export default {
  83. name: "instock",
  84. data() {
  85. return {
  86. itemOption: itemOption,
  87. search: {},
  88. search2: {},
  89. form: {},
  90. form2: {},
  91. option: {},
  92. dataList: [],
  93. itemData: [],
  94. page: {
  95. pageSize: 20,
  96. currentPage: 1,
  97. total: 0,
  98. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  99. },
  100. page2: {
  101. pageSize: 20,
  102. currentPage: 1,
  103. total: 0,
  104. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  105. },
  106. show: true,
  107. detailData: {},
  108. loading: false,
  109. loading2: false,
  110. searchShow: true,
  111. inStockVisible: false,
  112. selectionList: [],
  113. };
  114. },
  115. components: {detailPage},
  116. async created() {
  117. this.option = await this.getColumnData(this.getColumnName(196), option);
  118. this.option.height = window.innerHeight - 210;
  119. this.itemOption.height = window.innerHeight - 410;
  120. this.getWorkDicts("financing_status").then(res => {
  121. this.findObject(this.itemOption.column, "status").dicData =
  122. res.data.data;
  123. });
  124. this.getWorkDicts("CMY_business_type").then(res => {
  125. this.findObject(this.itemOption.column, "businessType").dicData =
  126. res.data.data;
  127. });
  128. getStoragetree().then(res => {
  129. this.findObject(this.itemOption.column, "storageId").dicData =
  130. res.data.data;
  131. })
  132. this.getAllWorkDicts()
  133. if (this.$route.query.check && this.show) {
  134. this.editOpen({id: this.$route.query.check.srcBillId}, 1)
  135. this.show = false;
  136. }
  137. },
  138. activated() {
  139. setTimeout(() => {
  140. if (this.$route.query.check && this.show) {
  141. this.editOpen({id: this.$route.query.check.srcBillId}, 1)
  142. this.show = false;
  143. }
  144. }, 100);
  145. },
  146. methods: {
  147. getAllWorkDicts() {
  148. this.getWorkDicts("approval_status").then(res => {
  149. this.findObject(this.option.column, "status").dicData =
  150. res.data.data;
  151. });
  152. this.getWorkDicts("CMY_business_type").then(res => {
  153. this.findObject(this.option.column, "businessType").dicData =
  154. res.data.data;
  155. });
  156. getStoragetree().then(res => {
  157. this.findObject(this.option.column, "storageId").dicData =
  158. res.data.data;
  159. })
  160. },
  161. searchCriteriaSwitch(type) {
  162. if (type) {
  163. this.option.height = this.option.height - 191;
  164. } else {
  165. this.option.height = this.option.height + 191;
  166. }
  167. this.$refs.crud.getTableHeight();
  168. },
  169. searchCriteriaSwitch2(type) {
  170. if (type) {
  171. this.itemOption.height = this.itemOption.height - 191;
  172. } else {
  173. this.itemOption.height = this.itemOption.height + 191;
  174. }
  175. this.$refs.crud2.getTableHeight();
  176. },
  177. cellStyle() {
  178. return "padding:0;height:40px;";
  179. },
  180. rowDel(row, index, done) {
  181. this.$confirm("确定删除数据?", {
  182. confirmButtonText: "确定",
  183. cancelButtonText: "取消",
  184. type: "warning"
  185. }).then(() => {
  186. remove({id: row.id}).then(res => {
  187. this.$message({
  188. type: "success",
  189. message: "删除成功!"
  190. });
  191. })
  192. .finally(() => {
  193. this.onLoad(this.page, this.search);
  194. });
  195. });
  196. },
  197. selectionChange(list) {
  198. this.selectionList = list;
  199. },
  200. generate() {
  201. if (this.selectionList.length == 1) {
  202. this.detailData = {
  203. generateId: this.selectionList[0].id,
  204. }
  205. this.show = false
  206. this.inStockVisible = false
  207. } else {
  208. this.$message.error('请选择一条数据')
  209. }
  210. },
  211. editOpen(row, status) {
  212. this.detailData = {
  213. id: row.id,
  214. status: status
  215. };
  216. this.show = false;
  217. },
  218. //点击搜索按钮触发
  219. searchChange(params, done) {
  220. this.page.currentPage = 1;
  221. this.onLoad(this.page, params);
  222. done();
  223. },
  224. searchChange2(params, done) {
  225. this.page2.currentPage = 1;
  226. this.onLoad2(this.page, params);
  227. done();
  228. },
  229. currentChange(val) {
  230. this.page.currentPage = val;
  231. },
  232. currentChange2(val) {
  233. this.page2.currentPage = val;
  234. },
  235. sizeChange(val) {
  236. this.page.currentPage = 1;
  237. this.page.pageSize = val;
  238. },
  239. sizeChange2(val) {
  240. this.page2.currentPage = 1;
  241. this.page2.pageSize = val;
  242. },
  243. onLoad(page, params) {
  244. if (this.search.stockTime && this.search.stockTime.length > 0) {
  245. params = {
  246. ...params,
  247. createStartTime: this.search.stockTime[0] + ' ' + "00:00:00",
  248. createEndTime: this.search.stockTime[1] + ' ' + "23:59:59"
  249. };
  250. }
  251. let data = this.deepClone(Object.assign({}, params, this.search));
  252. delete data.stockTime;
  253. data.billType = "PD"
  254. this.loading = true;
  255. getList(page.currentPage, page.pageSize, data)
  256. .then(res => {
  257. this.dataList = res.data.data.records ? res.data.data.records : [];
  258. this.page.total = res.data.data.total;
  259. })
  260. .finally(() => {
  261. this.loading = false;
  262. });
  263. },
  264. onLoad2(page, params) {
  265. if (this.search2.stockTime && this.search2.stockTime.length > 0) {
  266. params = {
  267. ...params,
  268. createStartTime: this.search2.stockTime[0] + ' ' + "00:00:00",
  269. createEndTime: this.search2.stockTime[1] + ' ' + "23:59:59"
  270. };
  271. }
  272. let data = this.deepClone(Object.assign({}, params, this.search2));
  273. delete data.stockTime;
  274. data.billType = "RK"
  275. data.statuss = 5
  276. this.loading2 = true;
  277. data.pdStatus = 'PD'
  278. getList(page.currentPage, page.pageSize, data)
  279. .then(res => {
  280. this.itemData = res.data.data.records ? res.data.data.records : [];
  281. this.page2.total = res.data.data.total;
  282. })
  283. .finally(() => {
  284. this.loading2 = false;
  285. });
  286. },
  287. refreshChange() {
  288. this.onLoad(this.page, this.search);
  289. },
  290. refreshChange2() {
  291. this.onLoad2(this.page2, this.search2);
  292. },
  293. newAdd() {
  294. this.inStockVisible = true;
  295. },
  296. goBack() {
  297. if (this.$route.query.check) {
  298. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  299. this.$router.push({
  300. path: "/InventoryManagement/inventory/index"
  301. });
  302. }
  303. this.detailData = this.$options.data().detailData;
  304. this.show = true;
  305. this.onLoad(this.page, this.search);
  306. },
  307. close() {
  308. this.$refs.crud2.refreshTable()
  309. },
  310. async saveColumn() {
  311. const inSave = await this.saveColumnData(
  312. this.getColumnName(196),
  313. this.option
  314. );
  315. if (inSave) {
  316. this.$nextTick(() => {
  317. this.$refs.crud.doLayout();
  318. });
  319. this.$message.success("保存成功");
  320. //关闭窗口
  321. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  322. }
  323. },
  324. async resetColumn() {
  325. this.option = option;
  326. const inSave = await this.delColumnData(this.getColumnName(196), this.option);
  327. if (inSave) {
  328. this.$nextTick(() => {
  329. this.$refs.crud.doLayout();
  330. });
  331. this.getAllWorkDicts()
  332. this.$message.success("重置成功");
  333. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  334. }
  335. }
  336. }
  337. };
  338. </script>
  339. <style scoped>
  340. ::v-deep .select-component {
  341. display: flex;
  342. }
  343. .page-crad ::v-deep .basic-container__card {
  344. height: 94.2vh;
  345. }
  346. .itemTable ::v-deep .el-table {
  347. width: 738px;
  348. }
  349. </style>