newSetStock.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. <template>
  2. <div class="newApply pagePadding">
  3. {{ ruleForm }}
  4. <div
  5. v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
  6. >
  7. <el-divider content-position="center">备货申请详情</el-divider>
  8. <el-form
  9. :model="ruleForm"
  10. :rules="rules"
  11. ref="ruleForm"
  12. label-width="120px"
  13. disabled="true"
  14. >
  15. <el-row>
  16. <el-col :span="12">
  17. <el-form-item label="商品名称" prop="goods_name">
  18. <el-input
  19. style="width: 100%"
  20. v-model="ruleForm.goods_name"
  21. placeholder="请输入内容"
  22. :size="searchSize"
  23. ></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <!-- <el-col :span="12">
  27. <el-form-item label="商品数量" prop="goods_name">
  28. <el-input
  29. style="width: 100%"
  30. v-model="ruleForm.goods_name"
  31. placeholder="请输入内容"
  32. :size="searchSize"
  33. ></el-input>
  34. </el-form-item>
  35. </el-col> -->
  36. <el-col :span="12">
  37. <el-form-item label="采购数量" prop="goods_num">
  38. <el-input
  39. style="width: 100%"
  40. v-model="ruleForm.goods_num"
  41. placeholder="请输入内容"
  42. :size="searchSize"
  43. ></el-input>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. <el-row>
  48. <el-col :span="12">
  49. <el-form-item label="最晚入库时间" prop="last_go_time">
  50. <el-date-picker
  51. style="width: 100%"
  52. :size="searchSize"
  53. v-model="ruleForm.last_go_time"
  54. type="date"
  55. value-format="timestamp"
  56. placeholder="选择日期"
  57. @change="selectTime"
  58. >
  59. </el-date-picker>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="12">
  63. <el-form-item label="入库仓库" prop="stock_in_rule">
  64. <el-cascader
  65. placeholder="请选择入库仓库"
  66. filterable
  67. clearable
  68. :size="searchSize"
  69. v-model="ruleForm.stock_in_rule"
  70. :options="options"
  71. style="width: 100%"
  72. @change="
  73. pageInfo.curr = 1;
  74. parmValue.page = 1;
  75. stockName();
  76. "
  77. ></el-cascader>
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. <!-- <el-row>
  82. <el-col :span="12">
  83. <el-form-item label="收件人" prop="consignee">
  84. <search-account
  85. :value="ruleForm.consignee"
  86. :size="searchSize"
  87. style="width: 100%"
  88. @searchChange="handleResignName"
  89. />
  90. </el-form-item>
  91. </el-col>
  92. <el-col :span="12">
  93. <el-form-item label="电话" prop="mobile">
  94. <el-input
  95. v-model="ruleForm.mobile"
  96. placeholder="请输入电话"
  97. :size="searchSize"
  98. style="width: 100%"
  99. />
  100. </el-form-item>
  101. </el-col>
  102. </el-row> -->
  103. <!-- <el-row>
  104. <el-col :span="12">
  105. <el-form-item label="收货地址" prop="receivedArea">
  106. <select-area
  107. :value="ruleForm.receivedArea"
  108. :size="searchSize"
  109. :placeholder="'请输入收货地址'"
  110. style="width: 100%"
  111. @selectChange="selectArea"
  112. />
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="12">
  116. <el-form-item label="详细地址" prop="detailArea">
  117. <el-input
  118. :size="searchSize"
  119. v-model="ruleForm.detailArea"
  120. style="width: 100%"
  121. placeholder="详细地址"
  122. />
  123. </el-form-item>
  124. </el-col>
  125. </el-row> -->
  126. <!-- <el-row>
  127. <el-col :span="12">
  128. <el-form-item label="物流单号" prop="express_number">
  129. <el-input
  130. :size="searchSize"
  131. style="width: 100%"
  132. placeholder="物流单号"
  133. v-model="ruleForm.express_number"
  134. /> </el-form-item
  135. ></el-col>
  136. <el-col :span="12">
  137. <el-form-item label="发货时间" prop="send_out_time">
  138. <el-date-picker
  139. style="width: 100%"
  140. :size="searchSize"
  141. v-model="ruleForm.send_out_time"
  142. value-format="timestamp"
  143. type="date"
  144. placeholder="选择日期"
  145. @change="selectOutTime"
  146. >
  147. </el-date-picker> </el-form-item
  148. ></el-col>
  149. </el-row> -->
  150. <!-- <el-form-item>
  151. <el-col :span="24" style="text-align: right; margin-top: 10px">
  152. <el-button type="primary" @click="save('ruleForm')"
  153. >保 存
  154. </el-button>
  155. <el-button type="warning" @click="submitForm('ruleForm')"
  156. >保 存 并 发 起 流 程
  157. </el-button>
  158. </el-col>
  159. </el-form-item> -->
  160. </el-form>
  161. <el-divider content-position="center">采购反馈</el-divider>
  162. <el-form
  163. :model="ruleForm"
  164. :rules="ruless"
  165. ref="ruleForm"
  166. label-width="120px"
  167. >
  168. <el-row>
  169. <el-col :span="12">
  170. <el-form-item label="出库仓库" prop="stock_go_rule">
  171. <el-cascader
  172. placeholder="请选择出库仓库"
  173. filterable
  174. clearable
  175. :size="searchSize"
  176. v-model="ruleForm.stock_go_rule"
  177. :options="options"
  178. style="width: 100%"
  179. @change="
  180. pageInfo.curr = 1;
  181. parmValue.page = 1;
  182. stockName();
  183. "
  184. ></el-cascader> </el-form-item
  185. ></el-col>
  186. <el-col :span="12">
  187. <el-form-item label="预计入库时间" prop="expect_go_stock">
  188. <el-date-picker
  189. style="width: 100%"
  190. :size="searchSize"
  191. v-model="ruleForm.expect_go_stock"
  192. type="date"
  193. value-format="timestamp"
  194. placeholder="选择日期"
  195. @change="selectTime"
  196. >
  197. </el-date-picker> </el-form-item
  198. ></el-col>
  199. </el-row>
  200. <el-row>
  201. <el-col :span="12"
  202. ><el-form-item label="采购数量上限" prop="goods_num_limit">
  203. <el-input
  204. style="width: 100%"
  205. v-model="ruleForm.goods_num_limit"
  206. placeholder="请输入数量上限"
  207. :size="searchSize"
  208. ></el-input> </el-form-item
  209. ></el-col>
  210. </el-row>
  211. <el-row>
  212. <el-col :span="12"
  213. ><el-form-item label="备注" prop="remark">
  214. <el-input
  215. type="textarea"
  216. placeholder="请输入备注"
  217. v-model="ruleForm.remark"
  218. :autosize="{ minRows: 2, maxRows: 6 }"
  219. /> </el-form-item
  220. ></el-col>
  221. </el-row>
  222. <el-form-item>
  223. <el-col :span="24" style="text-align: right; margin-top: 10px">
  224. <el-button type="primary" @click="save('ruleForm')"
  225. >保 存
  226. </el-button>
  227. <el-button type="warning" @click="submitForm('ruleForm')"
  228. >保 存 并 发 起 流 程
  229. </el-button>
  230. </el-col>
  231. </el-form-item>
  232. </el-form>
  233. </div>
  234. <div v-else>
  235. <no-auth></no-auth>
  236. </div>
  237. </div>
  238. </template>
  239. <script>
  240. import mixinPage from "@/mixins/elPaginationHandle";
  241. import resToken from "@/mixins/resToken";
  242. // import statusList from "@/assets/js/statusList";
  243. // import asyncRequest from "@/apis/service/stock/newApply";
  244. import asyncRequest from "@/apis/service/purchaseIn/storeManageFlow";
  245. import { mapGetters } from "vuex";
  246. import { isMobile, isAlphanumeric } from "@/utils/validate";
  247. export default {
  248. name: "allotFlow",
  249. mixins: [mixinPage, resToken],
  250. computed: {
  251. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  252. powers() {
  253. let tran =
  254. this.$store.getters.btnList.find(
  255. (item) => item.menu_route == "allotFlow"
  256. ) || {};
  257. if (tran && tran.action && tran.action.length > 0) {
  258. return tran.action;
  259. } else {
  260. return [];
  261. }
  262. },
  263. },
  264. data() {
  265. const validatemobile = (rule, value, callback) => {
  266. if (value === "") {
  267. callback(new Error("手机号不能为空!"));
  268. } else {
  269. if (!isMobile(value)) {
  270. callback(new Error("手机号格式不正确!"));
  271. } else {
  272. callback();
  273. }
  274. }
  275. };
  276. const validateExpressNumber = (rule, value, callback) => {
  277. if (value === "") {
  278. callback(new Error("物流单号不能为空!"));
  279. } else {
  280. if (!isAlphanumeric(value)) {
  281. callback(new Error("物流单号为6-16位数字字母组合!"));
  282. } else if (value.length < 6 || value.length > 16) {
  283. callback(new Error("物流单号为6-16位数字字母组合!"));
  284. } else {
  285. callback();
  286. }
  287. }
  288. };
  289. return {
  290. inTime: "",
  291. goTime: "",
  292. ruleForm: {
  293. goods_name: "", //商品名称
  294. goods_num: "", //商品数量
  295. last_go_time: "", //最晚入库时间
  296. stock_in_rule: "", //入库仓库
  297. goods_num_limit: "", //采购数量上限
  298. expect_go_time: "", //预计入库时间
  299. stock_go_rule: "", //出库仓库
  300. remark: "", //备注
  301. },
  302. rules: {
  303. //出入库规则
  304. goods_name: [
  305. {
  306. required: true,
  307. message: "商品名称不能为空",
  308. trigger: "blur",
  309. },
  310. ],
  311. goods_num: [
  312. {
  313. required: true,
  314. message: "请选择入库仓库",
  315. trigger: "blur",
  316. },
  317. ],
  318. last_go_time: [
  319. {
  320. // type: "date",
  321. required: true,
  322. message: "请输入入库最晚时间",
  323. // trigger: "blur" ,
  324. trigger: ["blur", "change"],
  325. },
  326. ],
  327. stock_in_rule: [
  328. {
  329. required: true,
  330. message: "请选择入库仓库",
  331. trigger: "change",
  332. },
  333. ],
  334. consignee: [
  335. {
  336. type: "array",
  337. required: true,
  338. message: "收货人不能为空",
  339. trigger: "change",
  340. },
  341. ],
  342. mobile: [
  343. {
  344. required: true,
  345. message: "电话号不能为空",
  346. trigger: "blur",
  347. },
  348. {
  349. validator: validatemobile,
  350. },
  351. ],
  352. receivedArea: [
  353. {
  354. type: "array",
  355. required: true,
  356. message: "收货地址不能为空",
  357. trigger: "change",
  358. },
  359. ],
  360. detailArea: [
  361. {
  362. required: true,
  363. message: "请输入详细地址",
  364. trigger: "blur",
  365. },
  366. ],
  367. express_number: [
  368. {
  369. required: true,
  370. message: "请输入快递单号",
  371. trigger: "blur",
  372. },
  373. {
  374. validator: validateExpressNumber,
  375. },
  376. ],
  377. send_out_time: [
  378. {
  379. required: true,
  380. message: "请输发货时间",
  381. trigger: ["blur", "change"],
  382. },
  383. ],
  384. },
  385. ruless: {
  386. stock_go_rule: [
  387. {
  388. required: true,
  389. message: "请选择出库仓库",
  390. trigger: "change",
  391. },
  392. ],
  393. goods_num_limit: [
  394. {
  395. required: true,
  396. message: "请输入数量上限",
  397. trigger: "blur",
  398. },
  399. ],
  400. expect_go_stock: [
  401. {
  402. // type: "date",
  403. required: true,
  404. message: "请输入入库最晚时间",
  405. // trigger: "blur" ,
  406. trigger: ["blur", "change"],
  407. },
  408. ],
  409. remark: [
  410. {
  411. required: true,
  412. message: "请输入备注",
  413. trigger: "blur",
  414. },
  415. ],
  416. },
  417. loading: true,
  418. showModel: false,
  419. isDetail: false,
  420. modelId: 0,
  421. tableData: [], //渲染表格
  422. //
  423. // 表格 - 数据
  424. tableData: [],
  425. // 表格 - 参数
  426. table: {
  427. stripe: true,
  428. border: true,
  429. // _defaultHeader_: ["setcol"],
  430. },
  431. // 表格 - 分页
  432. pageInfo: {
  433. size: 15,
  434. curr: 1,
  435. total: 0,
  436. },
  437. // 表格 - 列参数
  438. columns: [
  439. {
  440. prop: "nickname",
  441. label: "商品编号",
  442. },
  443. {
  444. prop: "role_name",
  445. label: "商品名称",
  446. },
  447. {
  448. prop: "mobile",
  449. label: "数量",
  450. },
  451. {
  452. prop: "",
  453. label: "操作",
  454. fixed: "right",
  455. _noset_: true,
  456. _slot_: "operation",
  457. },
  458. ],
  459. parmValue: {},
  460. };
  461. },
  462. methods: {
  463. // 选择省市区
  464. selectArea(e) {
  465. // console.log(e);
  466. if (e && e.length == 3) {
  467. this.ruleForm.receivedArea = e;
  468. } else {
  469. this.ruleForm.consignee = [];
  470. }
  471. // console.log(this.ruleForm);
  472. this.$refs.ruleForm.validateField("receivedArea");
  473. },
  474. // 选择收获人
  475. handleResignName(e) {
  476. if (e && e.id) {
  477. this.ruleForm.consignee = [e.id];
  478. } else {
  479. this.ruleForm.consignee = [];
  480. }
  481. this.$refs.ruleForm.validateField("consignee");
  482. },
  483. // 最晚入库时间选择
  484. selectTime(e) {
  485. console.log(e);
  486. this.ruleForm.goTime = e;
  487. },
  488. // 发货时间选择
  489. selectOutTime(e) {
  490. console.log(e);
  491. },
  492. // 保存按钮
  493. save(formName) {
  494. console.log("save");
  495. this.$refs[formName].validate((valid) => {
  496. if (valid) {
  497. alert("submit!");
  498. } else {
  499. console.log("error submit!!");
  500. return false;
  501. }
  502. });
  503. if (this.ruleForm.goTime < this.ruleForm.send_out_time) {
  504. this.$message({
  505. showClose: true,
  506. message: "最晚入库时间不能小于发货时间",
  507. type: "error",
  508. });
  509. }
  510. },
  511. submitForm(formName) {
  512. console.log("sds");
  513. console.log(formName);
  514. this.$refs[formName].validate((valid) => {
  515. if (valid) {
  516. alert("submit!");
  517. } else {
  518. console.log("error submit!!");
  519. return false;
  520. }
  521. });
  522. if (this.ruleForm.goTime < this.ruleForm.send_out_time) {
  523. this.$message({
  524. showClose: true,
  525. message: "最晚入库时间不能小于发货时间",
  526. type: "error",
  527. });
  528. }
  529. },
  530. },
  531. restSearch() {
  532. //重置入参
  533. this.parmValue = {};
  534. // this.searchList();
  535. },
  536. openModal(id, isDetail, sitem) {
  537. this.showModel = isDetail;
  538. this.modelId = id;
  539. this.isDetail = isDetail;
  540. this.sitem = sitem;
  541. },
  542. async deleteById(id, status) {
  543. // await this.$confirm("确定要删除?", {
  544. // confirmButtonText: "确定",
  545. // cancelButtonText: "取消",
  546. // type: "warning",
  547. // })
  548. // .then(async () => {
  549. // const model = {
  550. // id: id,
  551. // status: status === "1" ? "0" : "1",
  552. // };
  553. // const res = await asyncRequest.status(model);
  554. // if (res && res.code === 0) {
  555. // this.$notify.success({
  556. // title: "删除成功",
  557. // message: "",
  558. // });
  559. // this.searchList();
  560. // } else if (res && res.code >= 100 && res.code <= 104) {
  561. // await this.logout();
  562. // } else {
  563. // this.$message.warning(res.message);
  564. // }
  565. // })
  566. // .catch(() => {
  567. // console.log("取消");
  568. // });
  569. },
  570. async searchList() {
  571. // this.loading = true;
  572. // const res = await asyncRequest.list(this.parmValue);
  573. // if (res && res.code === 0 && res.data) {
  574. // this.tableData = res.data.list;
  575. // this.pageInfo.total = Number(res.data.count);
  576. // } else if (res && res.code >= 100 && res.code <= 104) {
  577. // await this.logout();
  578. // } else {
  579. // this.tableData = [];
  580. // this.pageInfo.total = 0;
  581. // }
  582. // this.loading = false;
  583. },
  584. async statusConfirm(id, status) {
  585. // let str = status === "1" ? "禁用" : "启用";
  586. // await this.$confirm("确定要改为" + str + "?", {
  587. // confirmButtonText: "确定",
  588. // cancelButtonText: "取消",
  589. // type: "warning",
  590. // })
  591. // .then(async () => {
  592. // this.loading = true;
  593. // const model = {
  594. // id: id,
  595. // status: status === "1" ? "0" : "1",
  596. // };
  597. // const res = await asyncRequest.status(model);
  598. // if (res && res.code === 0) {
  599. // this.loading = false;
  600. // this.$notify.success({
  601. // title: "状态修改成功!",
  602. // message: "",
  603. // });
  604. // await this.searchList();
  605. // } else if (res && res.code >= 100 && res.code <= 104) {
  606. // await this.logout();
  607. // } else {
  608. // this.$message.warning(res.message);
  609. // }
  610. // })
  611. // .catch(() => {
  612. // console.log("取消");
  613. // });
  614. },
  615. async stockName(isShowModal = false) {
  616. //获取多级仓库名称的方法
  617. const res = await asyncRequest.listAll(this.parmValue);
  618. console.log(res.data);
  619. // this.openModal("005", true);
  620. // console.log(this.selectStock_go);
  621. // console.log(this.selectStock_in);
  622. // this.options = res.data;
  623. // console.log(this.options);
  624. let arr = res.data;
  625. // console.log(arr);
  626. arr.forEach((ele) => {
  627. //重新封装后台传递来的数据,转换格式
  628. let item = {
  629. value: ele.id,
  630. label: ele.name,
  631. children: [],
  632. };
  633. ele.child.forEach((elem) => {
  634. let model = {
  635. value: elem.id,
  636. label: elem.name,
  637. };
  638. item.children.push(model);
  639. });
  640. this.options.push(item);
  641. });
  642. this.options.forEach((ele) => {
  643. //从数据表中筛选出我们要用的数据
  644. if (ele.value === this.selectStock_go[0]) {
  645. ele.children.forEach((elem) => {
  646. if (elem.value === this.selectStock_go[1]) {
  647. this.stock_go = ele.label + "/" + elem.label;
  648. }
  649. });
  650. }
  651. if (ele.value === this.selectStock_in[0]) {
  652. ele.children.forEach((elem) => {
  653. if (elem.value === this.selectStock_in[1]) {
  654. this.stock_in = ele.label + "/" + elem.label;
  655. }
  656. });
  657. }
  658. });
  659. if (this.selectStock_in != "" || this.selectStock_go != "") {
  660. console.log("选择了一个项目");
  661. this.openModal("005", isShowModal);
  662. }
  663. console.log(this.stock_go);
  664. console.log(this.stock_in);
  665. // if(){
  666. // }
  667. // console.log(this.pageInfo.total);
  668. this.compareStock(); //比较出库仓库和入库仓库是否相同
  669. },
  670. compareStock() {
  671. //比较出库仓库和入库仓库是否相同
  672. if (
  673. this.stock_go === this.stock_in &&
  674. this.stock_go !== "" &&
  675. this.stock_go != ""
  676. ) {
  677. console.log("出库仓库和入库仓库相同");
  678. this.$message({
  679. message: "出库仓库不能和入库仓库相同",
  680. type: "error",
  681. });
  682. }
  683. },
  684. };
  685. </script>
  686. <style lang="scss" >
  687. </style>