pickup_form.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. <el-col :xs="24" :sm="24" :lg="24">
  109. <el-form-item label="备注内容" prop="remark">
  110. <el-input v-model="mainForm.remark" :disabled="flag" placeholder="请输入备注内容"></el-input>
  111. </el-form-item>
  112. </el-col>
  113. </el-row>
  114. </el-form>
  115. </div>
  116. <div class="mymain-container">
  117. <div class="table">
  118. <el-table
  119. ref="table"
  120. v-loading="listLoading"
  121. :data="deliverList"
  122. element-loading-text="Loading"
  123. border
  124. fit
  125. highlight-current-row
  126. stripe
  127. @select="handleSelect"
  128. @select-all="handleSelectAll"
  129. >
  130. <el-table-column align="center" type="selection" width="55"></el-table-column>
  131. <template v-if="mainForm.pickupWay == 2 && logisticsNumber == '001'">
  132. <el-table-column align="left" label="收货客户" prop="orderTime" min-width="250" show-overflow-tooltip>
  133. <template slot-scope="scope">
  134. <el-input
  135. v-model="scope.row.receivingName"
  136. size="mini"
  137. @input="handleInput($event, scope.row.invoiceId, 1)"
  138. ></el-input>
  139. </template>
  140. </el-table-column>
  141. <el-table-column align="left" label="电话" prop="orderTime" min-width="250" show-overflow-tooltip>
  142. <template slot-scope="scope">
  143. <el-input
  144. v-model="scope.row.phone"
  145. size="mini"
  146. @input="handleInput($event, scope.row.invoiceId, 2)"
  147. ></el-input>
  148. </template>
  149. </el-table-column>
  150. <el-table-column align="left" label="收货地址" prop="orderTime" min-width="250" show-overflow-tooltip>
  151. <template slot-scope="scope">
  152. <el-input
  153. v-model="scope.row.address"
  154. size="mini"
  155. @input="handleInput($event, scope.row.invoiceId, 3)"
  156. ></el-input>
  157. </template>
  158. </el-table-column>
  159. </template>
  160. <el-table-column align="left" label="收货客户" prop="refLinkman" min-width="250" show-overflow-tooltip>
  161. <template slot-scope="scope">
  162. {{
  163. scope.row.enginOrderType === 'TRADE' || scope.row.enginOrderType === 'HOME' ? scope.row.refLinkman : ''
  164. }}
  165. </template>
  166. </el-table-column>
  167. <el-table-column align="left" label="电话" prop="refPhone" min-width="250" show-overflow-tooltip>
  168. <template slot-scope="scope">
  169. {{
  170. scope.row.enginOrderType === 'TRADE' || scope.row.enginOrderType === 'HOME' ? scope.row.refPhone : ''
  171. }}
  172. </template>
  173. </el-table-column>
  174. <el-table-column align="left" label="收货地址" prop="refInstallAddress" min-width="250" show-overflow-tooltip>
  175. <template slot-scope="scope">
  176. {{
  177. scope.row.enginOrderType === 'TRADE' || scope.row.enginOrderType === 'HOME'
  178. ? scope.row.refInstallAddress
  179. : ''
  180. }}
  181. </template>
  182. </el-table-column>
  183. <el-table-column
  184. align="left"
  185. label="发货申请单"
  186. prop="invoiceId"
  187. min-width="160"
  188. show-overflow-tooltip
  189. ></el-table-column>
  190. <el-table-column align="left" label="单据日期" prop="orderTime" min-width="120" show-overflow-tooltip>
  191. <template slot-scope="scope">
  192. {{ scope.row.orderTime | dateToDayFilter }}
  193. </template>
  194. </el-table-column>
  195. <el-table-column align="left" label="销售订单号" prop="mainOrderId" min-width="160" show-overflow-tooltip>
  196. <template slot-scope="scope">
  197. <CopyButton
  198. :copyText="
  199. scope.row.orderType === 'TRADE' ||
  200. scope.row.orderType === 'HOME' ||
  201. scope.row.orderType === 'REQUISITION_TRADE' ||
  202. scope.row.orderType === 'REQUISITION_HOME'
  203. ? scope.row.enginOrderNo
  204. : scope.row.mainOrderId
  205. "
  206. />
  207. <span>{{
  208. scope.row.orderType === 'TRADE' ||
  209. scope.row.orderType === 'HOME' ||
  210. scope.row.orderType === 'REQUISITION_TRADE' ||
  211. scope.row.orderType === 'REQUISITION_HOME'
  212. ? scope.row.enginOrderNo
  213. : scope.row.mainOrderId
  214. }}</span>
  215. </template>
  216. </el-table-column>
  217. <!-- <el-table-column align="left" label="工程编号" prop="enginOrderNo" min-width="140" show-overflow-tooltip></el-table-column> -->
  218. <el-table-column
  219. align="left"
  220. label="销售类型"
  221. prop="saleTypeName"
  222. min-width="160"
  223. show-overflow-tooltip
  224. ></el-table-column>
  225. <el-table-column
  226. align="left"
  227. label="物料编码"
  228. prop="materialCode"
  229. min-width="160"
  230. show-overflow-tooltip
  231. ></el-table-column>
  232. <el-table-column
  233. align="left"
  234. label="产品名称"
  235. prop="materialName"
  236. min-width="160"
  237. show-overflow-tooltip
  238. ></el-table-column>
  239. <el-table-column
  240. align="left"
  241. label="规格型号"
  242. prop="specification"
  243. min-width="160"
  244. show-overflow-tooltip
  245. ></el-table-column>
  246. <el-table-column
  247. align="left"
  248. label="单位"
  249. prop="unit"
  250. min-width="100"
  251. show-overflow-tooltip
  252. ></el-table-column>
  253. <el-table-column
  254. align="right"
  255. label="数量"
  256. prop="refundableQty"
  257. min-width="100"
  258. show-overflow-tooltip
  259. ></el-table-column>
  260. </el-table>
  261. </div>
  262. </div>
  263. <div class="page-footer">
  264. <div class="footer" :class="classObj">
  265. <el-button type="primary" @click="clickSubmitForm" v-if="!flag" :loading="formLoading">{{
  266. formLoading ? '提交中 ...' : '提 交'
  267. }}</el-button>
  268. <el-popconfirm title="确定重置吗?" @onConfirm="resetForm" style="margin-left: 10px" v-if="!listItem">
  269. <el-button slot="reference">重 置</el-button>
  270. </el-popconfirm>
  271. </div>
  272. </div>
  273. </div>
  274. </template>
  275. <script>
  276. import {
  277. getWarehouseList,
  278. getDeliverList,
  279. getPickupManList,
  280. getPickupCarList,
  281. getCompanyList,
  282. addPickupBook,
  283. editPickupBook,
  284. getDetail,
  285. checkStock
  286. } from '@/api/supply/pickup'
  287. import { getDictList } from '@/api/common'
  288. export default {
  289. name: 'PickupForm',
  290. componentName: 'PickupForm',
  291. props: ['listItem', 'flag'],
  292. data() {
  293. return {
  294. deliverList: null, // 列表数据
  295. listLoading: false, // 列表加载loading
  296. mainForm: {
  297. // 筛选表单数据
  298. warehouse: '',
  299. date: '',
  300. timeSlot: '',
  301. pickupWay: '',
  302. pickupMan: '',
  303. pickupCar: '',
  304. company: '',
  305. remark: '',
  306. logisticsId: ''
  307. },
  308. mainFormRules: {
  309. date: [{ required: true, message: '请选择预约日期', trigger: 'change' }],
  310. timeSlot: [{ required: true, message: '请选择预约时段', trigger: 'change' }],
  311. pickupWay: [{ required: true, message: '请选择提货方式', trigger: 'change' }],
  312. pickupMan: [{ 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. const item = this.companyList.find(k => k.id === e)
  439. this.mainForm.company = item.logisticsCompany
  440. this.logisticsNumber = item.logisticsNumber
  441. if (this.logisticsNumber === '001' && this.deliverList && this.deliverList.length) {
  442. this.deliverList.forEach(k => {
  443. this.$set(k, 'receivingName', '')
  444. this.$set(k, 'phone', '')
  445. this.$set(k, 'address', '')
  446. })
  447. } else {
  448. if (this.deliverList && !this.deliverList.length) return
  449. this.deliverList.forEach(k => {
  450. delete k.receivingName
  451. delete k.phone
  452. delete k.address
  453. })
  454. }
  455. },
  456. // 查询列表
  457. getDeliverList() {
  458. if (!this.mainForm.warehouse) {
  459. return this.$errorMsg('请选择仓库')
  460. }
  461. this.listLoading = true
  462. getDeliverList({ correspondId: this.mainForm.warehouse }).then(res => {
  463. this.deliverList = res.data
  464. this.listLoading = false
  465. })
  466. },
  467. handleSelect(selection, row) {
  468. this.$refs.table.toggleRowSelection(row)
  469. this.deliverList.forEach(item => {
  470. if (item.invoiceId === row.invoiceId) {
  471. this.$refs.table.toggleRowSelection(item)
  472. }
  473. })
  474. this.tableSelection = this.$refs.table.selection
  475. // this.tableSelection = this.$refs.table.selection;
  476. },
  477. handleSelectAll(selection) {
  478. this.tableSelection = this.$refs.table.selection
  479. },
  480. clickSubmitForm() {
  481. this.$refs.mainForm.validate(valid => {
  482. if (valid) {
  483. if (this.tableSelection.length < 1) {
  484. return this.$errorMsg('请选择发货申请单')
  485. }
  486. let orderList = []
  487. this.tableSelection.forEach(item => {
  488. orderList.push(item.invoiceOrderId)
  489. })
  490. let params = {
  491. correspondId: this.mainForm.warehouse,
  492. pickTime: this.mainForm.date + ' 00:00:00',
  493. invoiceOrderIds: orderList.join(',')
  494. }
  495. checkStock(params).then(res => {
  496. if (res.data) {
  497. this.$confirm(res.data, '提示', {
  498. confirmButtonText: '确定',
  499. cancelButtonText: '取消',
  500. type: 'warning'
  501. })
  502. .then(() => {
  503. this.submitForm()
  504. })
  505. .catch(() => {})
  506. } else {
  507. this.submitForm()
  508. }
  509. })
  510. }
  511. })
  512. },
  513. submitForm() {
  514. this.formLoading = true
  515. let takerName
  516. if (this.mainForm.pickupWay == '1') {
  517. takerName = this.pickupManList.find(o => o.id == this.mainForm.pickupMan).takerName
  518. }
  519. // let correspondName = this.warehouseList.find(o => o.id == this.mainForm.warehouse).name;
  520. let orderList = []
  521. this.tableSelection.forEach(item => {
  522. orderList.push({
  523. address: item.address,
  524. id: this.listItem ? item.id : '',
  525. invoiceOrderId: item.invoiceOrderId,
  526. materialCode: item.materialCode,
  527. materialId: item.materialId,
  528. materialName: item.materialName,
  529. materialOldNumber: item.materialOldNumber,
  530. phone: item.phone,
  531. pickActualTime: item.pickActualTime,
  532. pickId: item.pickId,
  533. printNum: item.printNum,
  534. printTime: item.printTime,
  535. receivingName: item.receivingName,
  536. status: item.status
  537. })
  538. })
  539. let params = {
  540. correspondId: this.mainForm.warehouse,
  541. // correspondName,
  542. pickTime: this.mainForm.date + ' 00:00:00',
  543. pickStatus: Number(this.mainForm.timeSlot),
  544. pickType: Number(this.mainForm.pickupWay),
  545. takerId: this.mainForm.pickupMan,
  546. takerName: takerName || '',
  547. remark: this.mainForm.remark,
  548. invoiceOrderIds: orderList
  549. }
  550. if (this.mainForm.pickupWay == '1') {
  551. params.takerCarId = this.mainForm.pickupCar
  552. }
  553. if (this.mainForm.pickupWay == '2') {
  554. params.pickLogistics = this.mainForm.company
  555. params.logisticsId = this.mainForm.logisticsId
  556. }
  557. if (this.listItem) {
  558. params.id = this.listItem.id
  559. editPickupBook(params)
  560. .then(res => {
  561. this.$successMsg('提交成功')
  562. this.goBack()
  563. this.$parent.getList()
  564. })
  565. .finally(res => {
  566. this.formLoading = false
  567. })
  568. } else {
  569. addPickupBook(params)
  570. .then(res => {
  571. this.$successMsg('提交成功')
  572. this.goBack()
  573. this.$parent.getList()
  574. })
  575. .finally(res => {
  576. this.formLoading = false
  577. })
  578. }
  579. },
  580. resetForm() {
  581. this.$refs.mainForm.resetFields()
  582. this.deliverList = []
  583. }
  584. }
  585. }
  586. </script>
  587. <style lang="scss" scoped></style>