pickup_form.vue 20 KB

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