pickup_form.vue 18 KB

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