index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <script>
  2. import test from "@/components/form-test/index.vue";
  3. import query from "@/components/query/index.vue";
  4. import byTable from "@/components/by-table/index.js";
  5. import sendSubscribe from "./sendSubscribe.vue";
  6. import subscribeDetails from "@/components/purchase/subscribeDetails.vue";
  7. import * as API from "@/api/purchase-management/subscribe/index.js";
  8. import { warehouseSelectList } from "@/api/product-material/warehouse/index.js";
  9. export default {
  10. components: {
  11. test,
  12. byTable,
  13. query,
  14. sendSubscribe,
  15. subscribeDetails,
  16. },
  17. data() {
  18. return {
  19. subscribeStatusList: [],
  20. productTypeList: [],
  21. materialTypeList: [],
  22. warehouseSelectList: [],
  23. warehouseTypeList: [],
  24. btnForm: {
  25. otherButton: {
  26. list: [
  27. {
  28. name: "发起申购",
  29. methodsText: "add",
  30. type: "primary",
  31. add: () => {
  32. this.handleAdd();
  33. },
  34. },
  35. ],
  36. },
  37. },
  38. queryParams: {
  39. pageNum: 1,
  40. pageSize: 10,
  41. keyword: "",
  42. warehouseId: "",
  43. status: null,
  44. code: "",
  45. goodsCode: "",
  46. goodsName: "",
  47. applyUserId: "",
  48. startTime: "",
  49. endTime: "",
  50. },
  51. selectConfig: [
  52. {
  53. label: "申购状态",
  54. prop: "status",
  55. data: [],
  56. },
  57. ],
  58. tableList: [],
  59. total: 0,
  60. loading: false,
  61. titleText: "",
  62. open: false,
  63. form: {
  64. id: "",
  65. receiptWarehouseId: "",
  66. planArrivalTime: "",
  67. cause: "",
  68. goodsId: [],
  69. },
  70. detailsDialog: false,
  71. rowData: {},
  72. };
  73. },
  74. created() {
  75. const businessDictData = JSON.parse(
  76. window.localStorage.getItem("businessDict")
  77. );
  78. this.productTypeList = businessDictData.find(
  79. (item) => item.code === "productType"
  80. ).children;
  81. this.subscribeStatusList = businessDictData.find(
  82. (item) => item.code === "purchaseStatus"
  83. ).children;
  84. this.warehouseTypeList = businessDictData.find(
  85. (item) => item.code === "warehouseType"
  86. ).children;
  87. this.materialTypeList = businessDictData.find(
  88. (item) => item.code === "materialType"
  89. ).children;
  90. this.selectConfig[0].data = this.subscribeStatusList.map((item) => ({
  91. label: item.dictValue,
  92. value: item.dictKey,
  93. }));
  94. warehouseSelectList().then((res) => {
  95. this.warehouseSelectList = res.data.data;
  96. });
  97. this.getList();
  98. },
  99. methods: {
  100. getList() {
  101. this.loading = true;
  102. API.subscribeList(this.queryParams).then(
  103. (res) => {
  104. this.tableList = res.data.data.records;
  105. this.total = res.data.data.total;
  106. this.loading = false;
  107. },
  108. (err) => {
  109. console.log("subscribeList: " + err);
  110. this.loading = false;
  111. }
  112. );
  113. },
  114. handleQuery() {
  115. this.getList();
  116. },
  117. handleAdd() {
  118. this.form = {
  119. id: "",
  120. receiptWarehouseId: "",
  121. planArrivalTime: "",
  122. cause: "",
  123. goodsId: [],
  124. };
  125. this.titleText = "add";
  126. this.open = true;
  127. },
  128. handleCancel() {
  129. this.open = false;
  130. },
  131. handleEdit(row) {
  132. this.titleText = "edit";
  133. this.open = true;
  134. this.$nextTick(() => {
  135. this.$refs.sendSubscribe.loading = true;
  136. API.subscribeDetails({ id: row.id }).then(
  137. (res) => {
  138. const data = res.data.data;
  139. const goodsItem = {
  140. goodsId: data.goodsId,
  141. quantity: data.quantity,
  142. code: data.goodsCode,
  143. name: data.goodsName,
  144. type: data.goodsType,
  145. unit: data.goodsUnit,
  146. stock: data.stockQuantity,
  147. };
  148. this.form = {
  149. id: data.id,
  150. receiptWarehouseId: data.receiptWarehouseId,
  151. planArrivalTime: data.planArrivalTime,
  152. cause: data.cause,
  153. goodsId: [goodsItem],
  154. };
  155. this.$refs.sendSubscribe.loading = false;
  156. },
  157. (err) => {
  158. console.log("subscribeDetails: ", err);
  159. this.$refs.sendSubscribe.loading = false;
  160. }
  161. );
  162. });
  163. },
  164. handleSubmit() {
  165. if (!this.form.id) {
  166. const productList = this.form.goodsId.map((x) => {
  167. return {
  168. ...x,
  169. planArrivalTime: this.form.planArrivalTime,
  170. receiptWarehouseId: this.form.receiptWarehouseId,
  171. cause: this.form.cause,
  172. };
  173. });
  174. API.subscribeAdd(productList).then(
  175. () => {
  176. this.msgSuccess("添加成功");
  177. this.$refs.sendSubscribe.loading = false;
  178. this.open = false;
  179. this.getList();
  180. },
  181. (err) => {
  182. console.log("subscribeAdd: " + err);
  183. this.$refs.sendSubscribe.loading = false;
  184. }
  185. );
  186. } else {
  187. this.form.quantity = this.form.goodsId[0].quantity;
  188. this.form.goodsId = this.form.goodsId[0].goodsId;
  189. API.subscribeEdit(this.form).then(
  190. () => {
  191. this.msgSuccess("编辑成功");
  192. this.open = false;
  193. this.$refs.sendSubscribe.loading = false;
  194. this.getList();
  195. },
  196. (err) => {
  197. console.log("subscribeEdit: " + err);
  198. this.$refs.sendSubscribe.loading = false;
  199. }
  200. );
  201. }
  202. },
  203. handleDelete(row) {
  204. this.$confirm("是否确认此操作 ?", {
  205. confirmButtonText: "确定",
  206. cancelButtonText: "取消",
  207. type: "warning",
  208. }).then(() => {
  209. API.subscribeDel({ id: row.id }).then(() => {
  210. this.msgSuccess("删除成功");
  211. this.getList();
  212. });
  213. });
  214. },
  215. showAddress(row) {
  216. return (
  217. <div>
  218. {row.countryName} , {row.provinceName} , {row.cityName}
  219. </div>
  220. );
  221. },
  222. handleLookDetails(row) {
  223. this.rowData = { ...row };
  224. this.detailsDialog = true;
  225. },
  226. },
  227. };
  228. </script>
  229. <template>
  230. <div class="box-card">
  231. <el-card class="header">
  232. <test :form-config="btnForm"></test>
  233. </el-card>
  234. <el-card class="body-main">
  235. <query
  236. :selectConfig="selectConfig"
  237. :req="queryParams"
  238. :isShowMore="true"
  239. @handleQuery="handleQuery"
  240. @handleMore="
  241. () => {
  242. queryDialog = true;
  243. }
  244. "
  245. ></query>
  246. <el-table :data="tableList" v-loading="loading">
  247. <el-table-column label="申购单号" align="left" prop="code" width="140">
  248. <template slot-scope="scope">
  249. <div class="show_underline" @click="handleLookDetails(scope.row)">
  250. {{ scope.row.code }}
  251. </div>
  252. </template>
  253. </el-table-column>
  254. <el-table-column
  255. label="物品编码"
  256. align="left"
  257. prop="goodsCode"
  258. width="120"
  259. />
  260. <el-table-column label="物品名称" align="left" prop="goodsName" />
  261. <el-table-column
  262. label="物品类型"
  263. align="left"
  264. width="100"
  265. :formatter="(row) => dictDataEcho(row.goodsType, productTypeList)"
  266. />
  267. <el-table-column
  268. label="单位"
  269. align="left"
  270. prop="goodsUnit"
  271. width="100"
  272. />
  273. <el-table-column
  274. label="申购数量"
  275. align="left"
  276. prop="quantity"
  277. width="120"
  278. />
  279. <el-table-column
  280. label="申购人"
  281. align="left"
  282. prop="createName"
  283. width="120"
  284. />
  285. <el-table-column
  286. label="申购时间"
  287. align="left"
  288. prop="createTime"
  289. width="160"
  290. :formatter="
  291. (row) => {
  292. return row.createTime.slice(0, 10);
  293. }
  294. "
  295. />
  296. <el-table-column
  297. label="要求到货时间"
  298. align="left"
  299. prop="planArrivalTime"
  300. width="160"
  301. :formatter="
  302. (row) => {
  303. return row.planArrivalTime.slice(0, 10);
  304. }
  305. "
  306. />
  307. <!-- <el-table-column
  308. :label="$t('purchase_management.subscribe.harvestWarehouse')"
  309. align="left"
  310. prop="warehouseName"
  311. /> -->
  312. <!--
  313. <el-table-column
  314. :label="$t('purchase_management.subscribe.subscribeReason')"
  315. align="left"
  316. prop="cause"
  317. /> -->
  318. <el-table-column
  319. label="采购状态"
  320. align="left"
  321. width="120"
  322. :formatter="(row) => dictDataEcho(row.status, subscribeStatusList)"
  323. />
  324. <!-- <el-table-column label="操作" align="center" width="120">
  325. <template slot-scope="scope">
  326. <el-button
  327. type="text"
  328. v-if="scope.row.status === 10"
  329. @click="handleEdit(scope.row)"
  330. >编辑
  331. </el-button>
  332. <el-button
  333. type="text"
  334. v-if="scope.row.status === 10"
  335. @click="handleDelete(scope.row)"
  336. >删除
  337. </el-button>
  338. </template>
  339. </el-table-column> -->
  340. </el-table>
  341. <pagination
  342. v-show="total > 0"
  343. :total="total"
  344. :page.sync="queryParams.pageNum"
  345. :limit.sync="queryParams.pageSize"
  346. @pagination="getList"
  347. />
  348. </el-card>
  349. <el-dialog
  350. :title="
  351. titleText === 'add'
  352. ? $t('purchase_management.subscribe.sendSubscribe')
  353. : $t('purchase_management.subscribe.subscribeEdit')
  354. "
  355. :visible.sync="open"
  356. v-if="open"
  357. width="80%"
  358. top="60px"
  359. >
  360. <send-subscribe
  361. :form="form"
  362. :productTypeList="productTypeList"
  363. :materialTypeList="materialTypeList"
  364. :warehouseSelectList="warehouseSelectList"
  365. :warehouseTypeList="warehouseTypeList"
  366. @submit="handleSubmit"
  367. @cancel="handleCancel"
  368. ref="sendSubscribe"
  369. ></send-subscribe>
  370. </el-dialog>
  371. <el-dialog
  372. title="申购详情"
  373. v-if="detailsDialog"
  374. :visible.sync="detailsDialog"
  375. width="50%"
  376. top="60px"
  377. >
  378. <subscribeDetails :rowData="rowData"></subscribeDetails>
  379. </el-dialog>
  380. </div>
  381. </template>
  382. <style lang="scss" scoped>
  383. .box-card {
  384. height: calc(100vh - 110px);
  385. overflow-y: auto;
  386. display: flex;
  387. flex-direction: column;
  388. .header {
  389. // height: 100px;
  390. margin-bottom: 10px;
  391. box-sizing: border-box;
  392. }
  393. .body-main {
  394. flex: 1;
  395. overflow-y: auto;
  396. }
  397. }
  398. </style>