pickup_form.vue 22 KB

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