pickup_form.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <div class="detail-container">
  3. <el-page-header
  4. @back="goBack"
  5. :content="listItem ? flag?'详情': '编辑' : '新增'"
  6. ></el-page-header>
  7. <el-divider></el-divider>
  8. <div>
  9. <el-form
  10. ref="mainForm"
  11. :model="mainForm"
  12. :rules="mainFormRules"
  13. label-width="80px"
  14. size="small"
  15. label-position="left"
  16. >
  17. <el-row :gutter="20">
  18. <el-col :xs="24" :sm="12" :lg="8">
  19. <el-form-item label="选择仓库" prop="warehouse">
  20. <el-select
  21. v-model="mainForm.warehouse"
  22. placeholder="请选择仓库"
  23. style="width: 100%"
  24. :disabled="flag"
  25. >
  26. <el-option
  27. :label="item.name"
  28. :value="item.id"
  29. v-for="(item, index) in warehouseList"
  30. :key="index"
  31. ></el-option>
  32. </el-select>
  33. </el-form-item>
  34. </el-col>
  35. <el-col :xs="24" :sm="12" :lg="8">
  36. <el-button size="small" type="primary" v-if="!flag" @click="getDeliverList"
  37. >确定</el-button
  38. >
  39. </el-col>
  40. </el-row>
  41. <el-row :gutter="20">
  42. <el-col :xs="24" :sm="12" :lg="8" style="height: 51px">
  43. <el-form-item label="预约日期" prop="date">
  44. <el-date-picker
  45. :disabled="flag"
  46. v-model="mainForm.date"
  47. type="date"
  48. value-format="yyyy-MM-dd"
  49. style="width: 100%"
  50. placeholder="选择日期"
  51. >
  52. </el-date-picker>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :xs="24" :sm="12" :lg="12" style="height: 51px">
  56. <el-form-item label="预约时段" prop="timeSlot">
  57. <el-radio-group v-model="mainForm.timeSlot" :disabled="flag">
  58. <el-radio :label="1">上午</el-radio>
  59. <el-radio :label="2">下午</el-radio>
  60. </el-radio-group>
  61. </el-form-item>
  62. </el-col>
  63. </el-row>
  64. <el-row :gutter="20">
  65. <el-col :xs="24" :sm="12" :lg="8">
  66. <el-form-item label="提货方式" prop="pickupWay">
  67. <el-radio-group v-model="mainForm.pickupWay" :disabled="flag">
  68. <el-radio
  69. :label="item.dictCode"
  70. v-for="(item, index) in pickupWayList"
  71. :key="index"
  72. >{{ item.dictValue }}</el-radio
  73. >
  74. </el-radio-group>
  75. </el-form-item>
  76. </el-col>
  77. <el-col :xs="24" :sm="12" :lg="8">
  78. <el-form-item label="提货人" prop="pickupMan" v-if="mainForm.pickupWay == '1'">
  79. <el-select
  80. v-model="mainForm.pickupMan"
  81. placeholder="全部"
  82. :disabled="flag"
  83. style="width: 100%"
  84. >
  85. <el-option
  86. :label="item.takerName"
  87. :value="item.id"
  88. v-for="(item, index) in pickupManList"
  89. :key="index"
  90. ></el-option>
  91. </el-select>
  92. </el-form-item>
  93. </el-col>
  94. <el-col :xs="24" :sm="12" :lg="8" v-if="mainForm.pickupWay == '1'">
  95. <el-form-item label="提货车辆" prop="pickupCar">
  96. <el-select
  97. v-model="mainForm.pickupCar"
  98. placeholder="全部"
  99. style="width: 100%"
  100. :disabled="flag"
  101. >
  102. <el-option
  103. :label="item.carBrand"
  104. :value="item.id"
  105. v-for="(item, index) in pickupCarList"
  106. :key="index"
  107. ></el-option>
  108. </el-select>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :xs="24" :sm="12" :lg="8" v-if="mainForm.pickupWay == '2'">
  112. <el-form-item label="物流公司" prop="company">
  113. <el-select
  114. v-model="mainForm.logisticsId"
  115. @change="getLogisticsId"
  116. placeholder="全部"
  117. style="width: 100%"
  118. :disabled="flag"
  119. >
  120. <el-option
  121. :label="item.logisticsCompany"
  122. :value="item.id"
  123. v-for="(item, index) in companyList"
  124. :key="index"
  125. ></el-option>
  126. </el-select>
  127. </el-form-item>
  128. </el-col>
  129. </el-row>
  130. <el-row :gutter="20">
  131. <el-col :xs="24" :sm="24" :lg="24">
  132. <el-form-item label="备注内容" prop="remark">
  133. <el-input
  134. v-model="mainForm.remark"
  135. :disabled="flag"
  136. placeholder="请输入备注内容"
  137. ></el-input>
  138. </el-form-item>
  139. </el-col>
  140. </el-row>
  141. </el-form>
  142. </div>
  143. <div class="mymain-container">
  144. <div class="table">
  145. <el-table
  146. ref="table"
  147. v-loading="listLoading"
  148. :data="deliverList"
  149. element-loading-text="Loading"
  150. border
  151. fit
  152. highlight-current-row
  153. stripe
  154. @select="handleSelect"
  155. @select-all="handleSelectAll"
  156. >
  157. <el-table-column
  158. align="center"
  159. type="selection"
  160. width="55"
  161. ></el-table-column>
  162. <el-table-column
  163. align="left"
  164. label="发货申请单"
  165. prop="invoiceId"
  166. min-width="160"
  167. show-overflow-tooltip
  168. ></el-table-column>
  169. <el-table-column
  170. align="left"
  171. label="单据日期"
  172. prop="orderTime"
  173. min-width="120"
  174. show-overflow-tooltip
  175. >
  176. <template slot-scope="scope">
  177. {{ scope.row.orderTime | dateToDayFilter }}
  178. </template>
  179. </el-table-column>
  180. <el-table-column
  181. align="left"
  182. label="销售订单号"
  183. prop="mainOrderId"
  184. min-width="160"
  185. show-overflow-tooltip
  186. >
  187. <template slot-scope="scope">
  188. <CopyButton :copyText='scope.row.orderType === "TRADE" ||
  189. scope.row.orderType === "HOME" || scope.row.orderType
  190. ==="REQUISITION_TRADE" || scope.row.orderType
  191. ==="REQUISITION_HOME"? scope.row.enginOrderNo:scope.row.mainOrderId' />
  192. <span>{{
  193. scope.row.orderType === "TRADE" ||
  194. scope.row.orderType === "HOME" ||
  195. scope.row.orderType === "REQUISITION_TRADE" ||
  196. scope.row.orderType === "REQUISITION_HOME"
  197. ? scope.row.enginOrderNo
  198. : scope.row.mainOrderId
  199. }}</span>
  200. </template>
  201. </el-table-column>
  202. <!-- <el-table-column align="left" label="工程编号" prop="enginOrderNo" min-width="140" show-overflow-tooltip></el-table-column> -->
  203. <el-table-column
  204. align="left"
  205. label="销售类型"
  206. prop="saleTypeName"
  207. min-width="160"
  208. show-overflow-tooltip
  209. ></el-table-column>
  210. <el-table-column
  211. align="left"
  212. label="物料编码"
  213. prop="materialCode"
  214. min-width="160"
  215. show-overflow-tooltip
  216. ></el-table-column>
  217. <el-table-column
  218. align="left"
  219. label="产品名称"
  220. prop="materialName"
  221. min-width="160"
  222. show-overflow-tooltip
  223. ></el-table-column>
  224. <el-table-column
  225. align="left"
  226. label="规格型号"
  227. prop="specification"
  228. min-width="160"
  229. show-overflow-tooltip
  230. ></el-table-column>
  231. <el-table-column
  232. align="left"
  233. label="单位"
  234. prop="unit"
  235. min-width="100"
  236. show-overflow-tooltip
  237. ></el-table-column>
  238. <el-table-column
  239. align="right"
  240. label="数量"
  241. prop="refundableQty"
  242. min-width="100"
  243. show-overflow-tooltip
  244. ></el-table-column>
  245. </el-table>
  246. </div>
  247. </div>
  248. <div class="page-footer">
  249. <div class="footer" :class="classObj">
  250. <el-button
  251. type="primary"
  252. @click="clickSubmitForm"
  253. v-if="!flag"
  254. :loading="formLoading"
  255. >{{ formLoading ? "提交中 ..." : "提 交" }}</el-button
  256. >
  257. <el-popconfirm
  258. title="确定重置吗?"
  259. @onConfirm="resetForm"
  260. style="margin-left: 10px"
  261. v-if="!listItem"
  262. >
  263. <el-button slot="reference">重 置</el-button>
  264. </el-popconfirm>
  265. </div>
  266. </div>
  267. </div>
  268. </template>
  269. <script>
  270. import {
  271. getWarehouseList,
  272. getDeliverList,
  273. getPickupManList,
  274. getPickupCarList,
  275. getCompanyList,
  276. addPickupBook,
  277. editPickupBook,
  278. getDetail,
  279. checkStock,
  280. } from "@/api/supply/pickup";
  281. import { getDictList } from "@/api/common";
  282. export default {
  283. name: "PickupForm",
  284. componentName: "PickupForm",
  285. props: ["listItem","flag"],
  286. data() {
  287. return {
  288. deliverList: null, // 列表数据
  289. listLoading: false, // 列表加载loading
  290. mainForm: {
  291. // 筛选表单数据
  292. warehouse: "",
  293. date: "",
  294. timeSlot: "",
  295. pickupWay: "",
  296. pickupMan: "",
  297. pickupCar: "",
  298. company: "",
  299. remark: "",
  300. logisticsId:""
  301. },
  302. mainFormRules: {
  303. date: [
  304. { required: true, message: "请选择预约日期", trigger: "change" },
  305. ],
  306. timeSlot: [
  307. { required: true, message: "请选择预约时段", trigger: "change" },
  308. ],
  309. pickupWay: [
  310. { required: true, message: "请选择提货方式", trigger: "change" },
  311. ],
  312. pickupMan: [
  313. { required: true, message: "请选择提货人", trigger: "change" },
  314. ],
  315. },
  316. formLoading: false,
  317. tableSelection: [],
  318. warehouseList: [],
  319. pickupWayList: [],
  320. pickupManList: [],
  321. pickupCarList: [],
  322. companyList: [],
  323. };
  324. },
  325. computed: {
  326. sidebar() {
  327. return this.$store.state.app.sidebar;
  328. },
  329. classObj() {
  330. return {
  331. hideSidebar: !this.sidebar.opened,
  332. openSidebar: this.sidebar.opened,
  333. };
  334. },
  335. },
  336. created() {
  337. this.getWarehouseList();
  338. this.getPickupWayList();
  339. this.getPickupManList();
  340. this.getPickupCarList();
  341. this.getCompanyList();
  342. if (this.listItem) {
  343. this.getDetail();
  344. }
  345. },
  346. methods: {
  347. // 查询按钮权限
  348. checkBtnRole(value) {
  349. // let btnRole = this.$route.meta.roles;
  350. // if(!btnRole) {return true}
  351. // let index = btnRole.indexOf(value);
  352. // return index >= 0;
  353. return true;
  354. },
  355. // 返回列表
  356. goBack() {
  357. this.$emit("backListFormDetail");
  358. },
  359. // 获取详情
  360. getDetail() {
  361. getDetail({ id: this.listItem.id }).then((res) => {
  362. let data = res.data;
  363. this.mainForm.warehouse = data.correspondId;
  364. this.mainForm.date = data.pickTime.slice(0, 10);
  365. this.mainForm.timeSlot = Number(data.pickStatus);
  366. this.mainForm.pickupWay = String(data.pickType);
  367. this.mainForm.pickupMan = data.takerId;
  368. this.mainForm.pickupCar = data.takerCarId;
  369. this.mainForm.company = data.pickLogistics;
  370. this.mainForm.remark = data.remark;
  371. this.mainForm.logisticsId = data.logisticsId
  372. this.deliverList = data.invoicePickBeans;
  373. });
  374. },
  375. // 获取仓库列表
  376. getWarehouseList() {
  377. getWarehouseList({
  378. pageNum: 1,
  379. pageSize: -1,
  380. }).then((res) => {
  381. this.warehouseList = res.data.records;
  382. });
  383. },
  384. // 获取提货方式列表
  385. getPickupWayList() {
  386. getDictList({ sysDictEnum: "PICK" }).then((res) => {
  387. this.pickupWayList = res.data;
  388. });
  389. },
  390. // 获取提货人列表
  391. getPickupManList() {
  392. getPickupManList({
  393. pageNum: 1,
  394. pageSize: -1,
  395. }).then((res) => {
  396. this.pickupManList = res.data.records;
  397. });
  398. },
  399. // 获取提货车辆列表
  400. getPickupCarList() {
  401. getPickupCarList({
  402. pageNum: 1,
  403. pageSize: -1,
  404. }).then((res) => {
  405. this.pickupCarList = res.data.records;
  406. });
  407. },
  408. // 获取物流公司列表
  409. getCompanyList() {
  410. getCompanyList({
  411. pageNum: 1,
  412. pageSize: -1,
  413. }).then((res) => {
  414. this.companyList = res.data.records;
  415. console.log(this.companyList);
  416. });
  417. },
  418. getLogisticsId(e){
  419. const item = this.companyList.find(k=>k.id===e)
  420. this.mainForm.company = item.logisticsCompany
  421. },
  422. // 查询列表
  423. getDeliverList() {
  424. if (!this.mainForm.warehouse) {
  425. return this.$errorMsg("请选择仓库");
  426. }
  427. this.listLoading = true;
  428. getDeliverList({ correspondId: this.mainForm.warehouse }).then((res) => {
  429. this.deliverList = res.data;
  430. this.listLoading = false;
  431. });
  432. },
  433. handleSelect(selection, row) {
  434. this.$refs.table.toggleRowSelection(row);
  435. this.deliverList.forEach((item) => {
  436. if (item.invoiceId === row.invoiceId) {
  437. this.$refs.table.toggleRowSelection(item);
  438. }
  439. });
  440. this.tableSelection = this.$refs.table.selection;
  441. // this.tableSelection = this.$refs.table.selection;
  442. },
  443. handleSelectAll(selection) {
  444. this.tableSelection = this.$refs.table.selection;
  445. },
  446. clickSubmitForm() {
  447. this.$refs.mainForm.validate((valid) => {
  448. if (valid) {
  449. if (this.tableSelection.length < 1) {
  450. return this.$errorMsg("请选择发货申请单");
  451. }
  452. let orderList = [];
  453. this.tableSelection.forEach((item) => {
  454. orderList.push(item.invoiceOrderId);
  455. });
  456. let params = {
  457. correspondId: this.mainForm.warehouse,
  458. pickTime: this.mainForm.date + " 00:00:00",
  459. invoiceOrderIds: orderList.join(","),
  460. };
  461. checkStock(params).then((res) => {
  462. if (res.data) {
  463. this.$confirm(res.data, "提示", {
  464. confirmButtonText: "确定",
  465. cancelButtonText: "取消",
  466. type: "warning",
  467. })
  468. .then(() => {
  469. this.submitForm();
  470. })
  471. .catch(() => {});
  472. } else {
  473. this.submitForm();
  474. }
  475. });
  476. }
  477. });
  478. },
  479. submitForm() {
  480. this.formLoading = true;
  481. let takerName
  482. if (this.mainForm.pickupWay == "1") {
  483. takerName = this.pickupManList.find(
  484. (o) => o.id == this.mainForm.pickupMan
  485. ).takerName ;
  486. }
  487. // let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
  488. let orderList = [];
  489. this.tableSelection.forEach((item) => {
  490. orderList.push(item.invoiceOrderId);
  491. });
  492. let params = {
  493. correspondId: this.mainForm.warehouse,
  494. // correspondName,
  495. pickTime: this.mainForm.date + " 00:00:00",
  496. pickStatus: Number(this.mainForm.timeSlot),
  497. pickType: Number(this.mainForm.pickupWay),
  498. takerId: this.mainForm.pickupMan,
  499. takerName:takerName||'',
  500. remark: this.mainForm.remark,
  501. invoiceOrderIds: orderList,
  502. };
  503. if (this.mainForm.pickupWay == "1") {
  504. params.takerCarId = this.mainForm.pickupCar;
  505. }
  506. if (this.mainForm.pickupWay == "2") {
  507. params.pickLogistics = this.mainForm.company;
  508. params.logisticsId = this.mainForm.logisticsId
  509. }
  510. if (this.listItem) {
  511. params.id = this.listItem.id;
  512. editPickupBook(params)
  513. .then((res) => {
  514. this.$successMsg("提交成功");
  515. this.goBack();
  516. this.$parent.getList();
  517. })
  518. .finally((res) => {
  519. this.formLoading = false;
  520. });
  521. } else {
  522. addPickupBook(params)
  523. .then((res) => {
  524. this.$successMsg("提交成功");
  525. this.goBack();
  526. this.$parent.getList();
  527. })
  528. .finally((res) => {
  529. this.formLoading = false;
  530. });
  531. }
  532. },
  533. resetForm() {
  534. this.$refs.mainForm.resetFields();
  535. this.deliverList = [];
  536. },
  537. },
  538. };
  539. </script>
  540. <style lang="scss" scoped></style>