pickup_form.vue 16 KB

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