WaybillManagement.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. <template>
  2. <!-- 运单管理 -->
  3. <div class="waybill_home">
  4. <actionBar :operateList="operateList" :formList="formList" :ruleForm="searchRuleForm" @openModel="openModel"
  5. @searchProtocol="searchProtocol"></actionBar>
  6. <div class="card_content">
  7. <!-- 表单 -->
  8. <tables ref="refWaybill" :suspension="true" :tableList="tableList" :tableData="tableData"
  9. @buttonData="buttonData">
  10. </tables>
  11. <!-- 分页 -->
  12. <div v-if="Total">
  13. <pagination :total="Total" :currentPage="Pagination.PageIndex" @changeSize="changeSize"
  14. @changeCurrent="changeCurrent">
  15. </pagination>
  16. </div>
  17. </div>
  18. <el-dialog :title="staffTitle" :visible.sync="staffDialogVisible" width="800px" :close-on-click-modal="false"
  19. @close="closePopup">
  20. <forms ref="userRules" :formNewList="personnelList" :ruleForm="personnelForm" labelWidth="80px"
  21. @remoteMethod="remoteSearch">
  22. </forms>
  23. <div class="waybill_item">
  24. <waybillForm ref="recipients" title="收件人" :conserveFlag="conserveFlag" thinTitle="收件人簿"
  25. :ruleForm="recipientsForm" @addressBook="getAddressBook('recipients')" @conserveSelect="conserveSelectil">
  26. </waybillForm>
  27. </div>
  28. <forms ref="childRules" :formNewList="formRuleList" :ruleForm="ruleForm" labelWidth="80px">
  29. </forms>
  30. <el-dialog width="60%" title="地址簿" :visible.sync="innerVisible" append-to-body>
  31. <div class="space_between_in" style="margin-bottom: 15px;">
  32. <div style="display: flex;align-items: center;width: 100%;">
  33. <h3 style="margin-left: 10px;flex: none;">搜索:</h3>
  34. <el-input v-model="bookInput" style="width: 100%;" placeholder="请输入姓名、电话、地址快速查找"
  35. @input="fastSearch()"></el-input>
  36. </div>
  37. </div>
  38. <div class="card_book_list">
  39. <!-- 表单 -->
  40. <tables :suspension="true" :tableList="bookTableList" :tableData="bookTableData" @cellClick="cellClick"
  41. @buttonData="buttonData">
  42. </tables>
  43. <!-- 分页 -->
  44. <div v-if="bookTotal">
  45. <pagination :total="bookTotal" :currentPage="bookPagination.PageIndex" @changeSize="bookChangeSize"
  46. @changeCurrent="bookChangeCurrent">
  47. </pagination>
  48. </div>
  49. </div>
  50. </el-dialog>
  51. <span slot="footer" class="dialog-footer">
  52. <el-button plain @click="staffDialogVisible = false">取 消</el-button>
  53. <el-button type="primary" :loading="confirmLoading" @click="handleAdd">确 定</el-button>
  54. </span>
  55. </el-dialog>
  56. <el-dialog title="派单" :visible.sync="sendDialogVisible" width="500px" :close-on-click-modal="false"
  57. @close="closeDialog">
  58. <forms ref="sendRules" :formNewList="sendRuleList" :ruleForm="sendRuleForm" labelWidth="80px"
  59. @handleScroll="handleScroll" @remoteMethod="remoteMethod">
  60. </forms>
  61. <span slot="footer" class="dialog-footer">
  62. <el-button plain @click="sendDialogVisible = false">取 消</el-button>
  63. <el-button type="primary" :loading="sendConfirmLoading" @click="sendHandleAdd">确 定</el-button>
  64. </span>
  65. </el-dialog>
  66. <el-dialog title="签收" :visible.sync="signDialogVisible" width="500px" :close-on-click-modal="false"
  67. @close="closeDialog1">
  68. <forms ref="signRules" :formNewList="signRuleList" :ruleForm="signRuleForm" labelWidth="80px">
  69. </forms>
  70. <span slot="footer" class="dialog-footer">
  71. <el-button plain @click="signDialogVisible = false">取 消</el-button>
  72. <el-button type="primary" :loading="signConfirmLoading" @click="signHandleAdd">确 定</el-button>
  73. </span>
  74. </el-dialog>
  75. <orderDetails ref="order" :waybillData="waybillData"></orderDetails>
  76. <el-dialog title="批量导入" :visible.sync="bulkImportVisible" width="600px" @close="closeDialog2">
  77. <div class="card_bulkImport">
  78. <el-upload ref="mYupload" class="upload-demo" accept=".xls,.xlsx" drag action="#" :limit="1" multiple
  79. :http-request="UploadImage">
  80. <i class="el-icon-upload"></i>
  81. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  82. <div class="el-upload__tip" slot="tip">请上传xls或者xlsx格式文件</div>
  83. </el-upload>
  84. <div style="margin-top: 15px;">
  85. <el-button size="medium" type="primary" icon="el-icon-upload" :loading="importFlag"
  86. @click="immediateImport">立即导入</el-button>
  87. <el-button size="medium" icon="el-icon-download" :loading="downloadFlag"
  88. @click="templateDownload">模板下载</el-button>
  89. </div>
  90. </div>
  91. </el-dialog>
  92. </div>
  93. </template>
  94. <script>
  95. import {
  96. getWaybill,
  97. addWaybill,
  98. putWaybill,
  99. delWaybill,
  100. waybillDelivery,
  101. waybillImport,
  102. exportTemplate,
  103. getReceipt
  104. } from '@/api/waybill'
  105. import {
  106. getAddress,
  107. addAddress,
  108. putAddress,
  109. delAddress
  110. } from '@/api/address'
  111. import {
  112. getCoolerBox
  113. } from '@/api/incubator.js'
  114. import {
  115. getUser
  116. } from '@/api/user'
  117. import actionBar from '@/components/actionBar'
  118. import tables from '@/components/tables'
  119. import pagination from '@/components/pagination'
  120. import waybillForm from '@/components/waybillForm'
  121. import forms from '@/components/forms'
  122. import orderDetails from '@/components/orderDetails'
  123. import {
  124. formRules,
  125. employee,
  126. addressBook,
  127. sendList,
  128. signList,
  129. consignmentList
  130. } from "./waybill.js";
  131. import {
  132. WaybillStatus
  133. } from '@/assets/js/blockSort'
  134. import {
  135. number
  136. } from 'echarts'
  137. export default {
  138. name: 'WaybillManagement',
  139. components: {
  140. actionBar,
  141. tables,
  142. pagination,
  143. waybillForm,
  144. forms,
  145. orderDetails
  146. },
  147. data() {
  148. return {
  149. operateList: [{
  150. type: 'sends',
  151. title: '批量派单',
  152. colour: 'success'
  153. }, {
  154. type: 'import',
  155. title: '批量导入',
  156. colour: 'warning'
  157. }, {
  158. type: 'add',
  159. title: '添加运单',
  160. icon: 'el-icon-plus',
  161. }],
  162. formList: [{
  163. type: 'input',
  164. label: '运单号',
  165. field: 'waybillNo',
  166. placeholder: '请输入运单号',
  167. }, {
  168. type: 'select',
  169. label: '状态',
  170. field: 'status',
  171. placeholder: '请选择状态',
  172. options: WaybillStatus(),
  173. }, {
  174. type: 'picker',
  175. label: '下单时间',
  176. field: 'time',
  177. placeholder: '下单时间',
  178. }],
  179. searchRuleForm: {
  180. waybillNo: '',
  181. status: null,
  182. time: [],
  183. },
  184. searchValue: {},
  185. Pagination: {
  186. PageIndex: 1,
  187. PageSize: 10,
  188. },
  189. Total: 0,
  190. bookPagination: {
  191. PageIndex: 1,
  192. PageSize: 10,
  193. },
  194. bookTotal: 0,
  195. tableData: [],
  196. operationType: '',
  197. tableList: employee(),
  198. confirmLoading: false,
  199. staffTitle: '添加',
  200. staffDialogVisible: false,
  201. senderForm: {
  202. name: '',
  203. phone: '',
  204. region: '',
  205. address: '',
  206. },
  207. recipientsForm: {
  208. name: '',
  209. phone: '',
  210. region: '',
  211. address: '',
  212. },
  213. delivererForm: {
  214. name: '',
  215. phone: '',
  216. },
  217. personnelList: consignmentList(),
  218. personnelForm: {
  219. reCheckId: null,
  220. deliveryId: null,
  221. },
  222. delivererName: '',
  223. ruleForm: {
  224. tamperProofLabel: '',
  225. tamperProofLabelImg: '',
  226. remark: '',
  227. fileList: [],
  228. },
  229. formRuleList: [],
  230. bookType: '',
  231. sendDialogVisible: false,
  232. sendRuleList: sendList(),
  233. sendRuleForm: {
  234. coolerBoxId: null,
  235. },
  236. sendConfirmLoading: false,
  237. orderId: null,
  238. waybillIdList: [],
  239. waybillData: {},
  240. bulkImportVisible: false,
  241. importFlag: false,
  242. downloadFlag: false,
  243. importFile: null,
  244. page: 1,
  245. staffName: '',
  246. limitNo: true,
  247. sendOrdersId: 2,
  248. signDialogVisible: false,
  249. signRuleList: signList(),
  250. signRuleForm: {
  251. status: '',
  252. rejectionReason: '',
  253. },
  254. signConfirmLoading: false,
  255. waybillNo: '',
  256. innerVisible: false,
  257. tabPosition: 'my',
  258. bookInput: '',
  259. bookTableList: [],
  260. bookTableData: [],
  261. bookTotal: 0,
  262. saveSenderAddress: true,
  263. saveConsigneeAddress: true,
  264. conserveFlag: true,
  265. }
  266. },
  267. mounted() {
  268. const dataList = formRules();
  269. this.formRuleList = dataList;
  270. this.getReviewerList()
  271. this.getDelivererList()
  272. this.getList()
  273. },
  274. methods: {
  275. // 搜索
  276. searchProtocol(value) {
  277. this.Pagination.PageIndex = 1
  278. this.searchValue = value
  279. if (value.time) {
  280. this.searchValue.orderStartTime = value.time[0]
  281. this.searchValue.orderEndTime = value.time[1]
  282. }
  283. this.getList()
  284. },
  285. // 获取订单列表
  286. getList() {
  287. var params = {
  288. page: this.Pagination.PageIndex,
  289. pageSize: this.Pagination.PageSize,
  290. ...this.searchValue
  291. }
  292. delete params.time
  293. getWaybill(params).then(res => {
  294. if (res.code == 200) {
  295. this.tableData = res.data.list
  296. this.tableData.forEach(item => {
  297. item.visible = false
  298. })
  299. this.Total = res.data.count
  300. }
  301. })
  302. },
  303. // 获取地址簿
  304. getAddressBook(type) {
  305. this.bookTableList = addressBook()
  306. this.bookType = type
  307. this.innerVisible = true
  308. this.getSenderSend()
  309. },
  310. // 获取寄/收列表
  311. getSenderSend() {
  312. let address = ''
  313. if (this.bookType == 'recipients') {
  314. address = 'consignee'
  315. } else {
  316. address = this.bookType
  317. }
  318. getAddress({
  319. page: this.bookPagination.PageIndex,
  320. pageSize: this.bookPagination.PageSize,
  321. name: this.bookInput,
  322. addressType: address,
  323. }).then(res => {
  324. if (res.code == 200) {
  325. this.bookTableData = res.data.list
  326. this.bookTotal = res.data.count
  327. }
  328. })
  329. },
  330. // 复核人
  331. getReviewerList() {
  332. var params = {
  333. page: 1,
  334. pageSize: 999,
  335. name: this.delivererName,
  336. }
  337. getUser(params).then(res => {
  338. if (res.code == 200) {
  339. let arr = res.data.list
  340. let arrList = []
  341. arr.forEach(item1 => {
  342. var arrData = {
  343. label: null,
  344. value: null,
  345. }
  346. arrData.label = item1.nickName
  347. arrData.value = item1.id
  348. arrList.push(arrData)
  349. })
  350. this.personnelList.forEach(item => {
  351. if (item.field == 'reCheckId') {
  352. item.options = item.options.concat(arrList)
  353. }
  354. })
  355. }
  356. })
  357. },
  358. remoteSearch(value, type) {
  359. this.delivererName = value
  360. if (type == 'deliveryId') {
  361. this.personnelList.forEach(item => {
  362. if (item.field == 'deliveryId') {
  363. item.options = []
  364. }
  365. })
  366. this.getDelivererList()
  367. } else if (type == 'reCheckId') {
  368. this.personnelList.forEach(item => {
  369. if (item.field == 'reCheckId') {
  370. item.options = []
  371. }
  372. })
  373. this.getReviewerList()
  374. }
  375. },
  376. // 获取配送人
  377. getDelivererBook(type) {
  378. this.bookType = type
  379. this.getDelivererList()
  380. },
  381. getDelivererList() {
  382. var params = {
  383. page: 1,
  384. pageSize: 999,
  385. type: 3,
  386. name: this.delivererName,
  387. }
  388. getUser(params).then(res => {
  389. if (res.code == 200) {
  390. let arr = res.data.list
  391. let arrList = []
  392. arr.forEach(item1 => {
  393. var arrData = {
  394. label: null,
  395. value: null,
  396. }
  397. arrData.label = item1.nickName
  398. arrData.value = item1.id
  399. arrList.push(arrData)
  400. })
  401. this.personnelList.forEach(item => {
  402. if (item.field == 'deliveryId') {
  403. item.options = item.options.concat(arrList)
  404. }
  405. })
  406. }
  407. })
  408. },
  409. // 选择是否保存
  410. conserveSelect(type) {
  411. if (type) {
  412. this.saveSenderAddress = true
  413. } else {
  414. this.saveSenderAddress = false
  415. }
  416. },
  417. conserveSelectil(type) {
  418. if (type) {
  419. this.saveConsigneeAddress = true
  420. } else {
  421. this.saveConsigneeAddress = false
  422. }
  423. },
  424. // 弹窗表单添加
  425. async handleAdd() {
  426. let senderFlag = this.$refs['userRules'].validateForm();
  427. let recipientsFlag = this.$refs['recipients'].validateForm();
  428. if (senderFlag && recipientsFlag) {
  429. this.confirmLoading = true
  430. var params = {
  431. // senderAddressName: this.senderForm.name,
  432. // senderAddressPhone: this.senderForm.phone,
  433. // senderAddressDetails: this.senderForm.address,
  434. consigneeAddressName: this.recipientsForm.name,
  435. consigneeAddressPhone: this.recipientsForm.phone,
  436. consigneeAddressDetails: this.recipientsForm.address,
  437. // deliveryName: this.delivererForm.name,
  438. // deliveryPhone: this.delivererForm.phone,
  439. // saveSenderAddress: this.saveSenderAddress,
  440. saveConsigneeAddress: this.saveConsigneeAddress,
  441. deliveryId: Number(this.personnelForm.deliveryId),
  442. reCheckId: Number(this.personnelForm.reCheckId),
  443. ...this.ruleForm
  444. }
  445. if (this.ruleForm.fileList) {
  446. var fileImage = this.picture(this.ruleForm.fileList)
  447. params.tamperProofLabelImg = fileImage
  448. }
  449. if (this.operationType == 'add') {
  450. delete params.fileList
  451. await addWaybill(params).then(res => {
  452. if (res.code == 200) {
  453. this.$message({
  454. message: '操作成功',
  455. type: 'success'
  456. });
  457. this.getList()
  458. }
  459. this.staffDialogVisible = false
  460. this.confirmLoading = false
  461. }).catch(() => {
  462. this.confirmLoading = false
  463. })
  464. } else if (this.operationType == 'edit') {
  465. delete params.fileList
  466. params.id = this.orderId
  467. await putWaybill(params).then(res => {
  468. if (res.code == 200) {
  469. this.$message({
  470. message: '操作成功',
  471. type: 'success'
  472. });
  473. this.getList()
  474. }
  475. this.staffDialogVisible = false
  476. this.confirmLoading = false
  477. }).catch(() => {
  478. this.confirmLoading = false
  479. })
  480. }
  481. } else {
  482. this.$message.error('表单信息不完整,请继续填写完整');
  483. }
  484. // console.log(this.ruleForm,86)
  485. // console.log(this.senderForm, this.recipientsForm, 665)
  486. },
  487. picture(arr) {
  488. var imgList = JSON.parse(JSON.stringify(arr))
  489. var imgArr = []
  490. imgList.forEach((item, index) => {
  491. imgArr.push(item.url)
  492. })
  493. var imgString = imgArr.join()
  494. return imgString
  495. },
  496. // 添加寄件人
  497. getSender(value) {
  498. return new Promise((resolve, reject) => {
  499. var params = {
  500. addressType: 'sender',
  501. ...value
  502. }
  503. params.provinceId = value.regionCode[0]
  504. params.cityId = value.regionCode[1]
  505. params.regionId = value.regionCode[2]
  506. const regionArr = value.region.split('/')
  507. params.provinceName = regionArr[0]
  508. params.cityName = regionArr[1]
  509. params.regionName = regionArr[2]
  510. delete params.regionCode
  511. delete params.region
  512. addAddress(params).then(res => {
  513. if (res.code == 200) {
  514. const orderID = res.data
  515. resolve(orderID);
  516. }
  517. }).catch((error) => {
  518. reject(error)
  519. })
  520. });
  521. },
  522. // 添加收件人
  523. getRecipients(value) {
  524. return new Promise((resolve, reject) => {
  525. var params = {
  526. addressType: 'consignee',
  527. ...value
  528. }
  529. params.provinceId = value.regionCode[0]
  530. params.cityId = value.regionCode[1]
  531. params.regionId = value.regionCode[2]
  532. const regionArr = value.region.split('/')
  533. params.provinceName = regionArr[0]
  534. params.cityName = regionArr[1]
  535. params.regionName = regionArr[2]
  536. delete params.regionCode
  537. delete params.region
  538. addAddress(params).then(res => {
  539. if (res.code == 200) {
  540. const orderID = res.data
  541. resolve(orderID);
  542. }
  543. }).catch((error) => {
  544. reject(error)
  545. })
  546. });
  547. },
  548. // 选择table其中某一项
  549. cellClick(row) {
  550. this.innerVisible = false
  551. const param = {
  552. ...row
  553. }
  554. if (this.bookType == 'sender') {
  555. this.senderForm = param
  556. this.$nextTick(() => {
  557. this.$refs.sender.radio = ''
  558. // this.$refs['sender'].clickitem('1')
  559. this.$refs['sender'].validateForm();
  560. })
  561. } else if (this.bookType == 'recipients') {
  562. this.recipientsForm = param
  563. this.$nextTick(() => {
  564. this.$refs.recipients.radio = ''
  565. // this.$refs['recipients'].clickitem('1')
  566. this.$refs['recipients'].validateForm();
  567. })
  568. } else if (this.bookType == 'deliverer') {
  569. this.delivererForm.name = param.nickName
  570. this.delivererForm.phone = param.phone
  571. this.$nextTick(() => {
  572. this.$refs['deliverer'].validateForm();
  573. })
  574. }
  575. },
  576. buttonData(row, type) {
  577. this.operationType = type
  578. this.orderId = row.id
  579. if (type == 'logs') {
  580. this.$refs.order.staffDialogVisible = true
  581. this.waybillData = row
  582. this.waybillData.coolerBoxName = row.coolerBox.name
  583. } else if (type == 'edit') {
  584. this.conserveFlag = false
  585. this.staffTitle = '编辑'
  586. this.staffDialogVisible = true
  587. setTimeout(() => {
  588. this.$nextTick(() => {
  589. // this.senderForm.name = row.senderAddressName
  590. // this.senderForm.phone = row.senderAddressPhone
  591. // this.senderForm.address = row.senderAddressDetails
  592. this.recipientsForm.name = row.consigneeAddressName
  593. this.recipientsForm.phone = row.consigneeAddressPhone
  594. this.recipientsForm.address = row.consigneeAddressDetails
  595. // this.delivererForm.name = row.deliveryName
  596. // this.delivererForm.phone = row.deliveryPhone
  597. this.ruleForm.tamperProofLabel = row.tamperProofLabel
  598. this.personnelForm.reCheckId = String(row.reCheckId)
  599. this.personnelForm.deliveryId = String(row.deliveryId)
  600. if (row.tamperProofLabelImg) {
  601. var arr = row.tamperProofLabelImg.split(',')
  602. var arr3 = []
  603. arr.forEach((item, index) => {
  604. var arr1 = {
  605. url: '',
  606. }
  607. arr1.url = item
  608. arr3.push(arr1)
  609. })
  610. this.ruleForm.fileList = arr3
  611. this.ruleForm.tamperProofLabelImg = row.tamperProofLabelImg
  612. }
  613. this.ruleForm.remark = row.remark
  614. })
  615. })
  616. } else if (type == 'send') {
  617. this.sendDialogVisible = true
  618. this.getUserList(2)
  619. } else if (type == 'del') {
  620. this.deleteUser(row.id)
  621. } else if (type == 'sign') {
  622. this.signDialogVisible = true
  623. this.waybillNo = row.waybillNo
  624. this.signRuleForm.status = row.status
  625. }
  626. },
  627. // 订单派单
  628. sendHandleAdd() {
  629. let flag = this.$refs['sendRules'].validateForm();
  630. if (flag) {
  631. this.sendConfirmLoading = true
  632. let arrID = []
  633. if (this.operationType == 'send') {
  634. arrID.push(this.orderId)
  635. } else if (this.operationType == 'sends') {
  636. arrID = this.waybillIdList
  637. }
  638. const param = {
  639. waybillIds: arrID,
  640. coolerBoxId: Number(this.sendRuleForm.coolerBoxId),
  641. }
  642. waybillDelivery(param).then(res => {
  643. if (res.code == 200) {
  644. this.$message({
  645. message: res.msg,
  646. type: 'success'
  647. });
  648. this.getList()
  649. }
  650. this.sendDialogVisible = false
  651. this.sendConfirmLoading = false
  652. }).catch(() => {
  653. this.sendConfirmLoading = false
  654. })
  655. } else {
  656. this.$message.error('表单信息不完整,请继续填写完整');
  657. }
  658. },
  659. // 签收
  660. signHandleAdd() {
  661. let flag = this.$refs['signRules'].validateForm();
  662. if (flag) {
  663. this.signConfirmLoading = true
  664. let params = {
  665. waybillNo: this.waybillNo,
  666. ...this.signRuleForm,
  667. }
  668. getReceipt(params).then(res => {
  669. if (res.code == 200) {
  670. this.$message({
  671. message: res.msg,
  672. type: 'success'
  673. });
  674. this.signDialogVisible = false
  675. }
  676. this.signConfirmLoading = false
  677. })
  678. } else {
  679. this.$message.error('表单信息不完整,请继续填写完整');
  680. }
  681. },
  682. // 删除用户
  683. deleteUser(id) {
  684. this.$confirm('此操作将永久该运单, 是否继续?', '提示', {
  685. confirmButtonText: '确定',
  686. cancelButtonText: '取消',
  687. type: 'warning'
  688. }).then(() => {
  689. delWaybill({
  690. id: id,
  691. }).then(res => {
  692. if (res.code == 200) {
  693. this.$message({
  694. message: '操作成功',
  695. type: 'success'
  696. });
  697. this.getList()
  698. }
  699. })
  700. }).catch(() => {});
  701. },
  702. // 重置选择员工
  703. resetSelect() {
  704. this.sendRuleList.forEach(item => {
  705. if (item.type == 'searchSelect') {
  706. item.options = []
  707. }
  708. })
  709. this.page = 1
  710. this.limitNo = true
  711. this.staffName = ''
  712. },
  713. // 触底事件
  714. handleScroll() {
  715. if (this.limitNo) {
  716. this.getUserList()
  717. }
  718. },
  719. // 搜索
  720. remoteMethod(value) {
  721. this.resetSelect()
  722. this.staffName = value
  723. this.getUserList(this.sendOrdersId)
  724. },
  725. // 获取保温箱列表
  726. getUserList(type) {
  727. let arrList = []
  728. let params = {
  729. page: this.page,
  730. pageSize: 10,
  731. name: this.staffName,
  732. }
  733. getCoolerBox(params).then(res => {
  734. if (res.code == 200) {
  735. let arr = res.data.list
  736. let arrList = []
  737. arr.forEach(item1 => {
  738. var arrData = {
  739. label: null,
  740. value: null,
  741. }
  742. arrData.label = item1.name
  743. arrData.value = item1.id
  744. arrList.push(arrData)
  745. })
  746. if (this.limitNo == true) {
  747. this.sendRuleList.forEach(item => {
  748. if (item.type == 'searchSelect') {
  749. item.options = item.options.concat(arrList);
  750. let some = [];
  751. item.options.forEach(el => {
  752. if (!some.some(e => e.value == el.value)) {
  753. some.push(el)
  754. }
  755. })
  756. item.options = some
  757. }
  758. })
  759. }
  760. if (arrList.length >= 10) {
  761. this.page = ++this.page;
  762. } else {
  763. // 已经没数据了 不需要增加数据
  764. this.limitNo = false;
  765. }
  766. }
  767. })
  768. },
  769. // 选项赋值
  770. optionMatching(value, field) {
  771. this.sendRuleList.forEach((item, index) => {
  772. if (item.field == field) {
  773. item.options = value
  774. }
  775. })
  776. },
  777. openModel(type) {
  778. this.operationType = type
  779. if (type == 'add') {
  780. this.conserveFlag = true
  781. this.staffTitle = '添加运单'
  782. this.staffDialogVisible = true
  783. this.$nextTick(() => {
  784. // this.$refs.sender.radio = '1'
  785. this.$refs.recipients.radio = '1'
  786. })
  787. } else if (type == 'sends') {
  788. const arrID = this.$refs.refWaybill.waybillIds
  789. if (arrID.length != 0) {
  790. let arr2 = []
  791. arrID.forEach(item => {
  792. if (item.status == 1 || item.status == 2) {
  793. arr2.push(item.id)
  794. }
  795. })
  796. this.waybillIdList = arr2
  797. if (arr2.length > 0) {
  798. this.sendDialogVisible = true
  799. this.getUserList(2)
  800. } else {
  801. this.$message({
  802. message: '请选择未派单的运单',
  803. type: 'warning'
  804. });
  805. }
  806. } else {
  807. this.$message({
  808. message: '请先选择需要批量操作的运单',
  809. type: 'warning'
  810. });
  811. }
  812. // console.log(type, arrID, '批量派单')
  813. } else if (type == 'import') {
  814. this.bulkImportVisible = true
  815. } else if (type == 'print') {
  816. const arrID = this.$refs.refWaybill.waybillIds
  817. if (arrID.length != 0) {
  818. let arr3 = []
  819. let arr4 = []
  820. arrID.forEach(item => {
  821. if (item.status == 8) {
  822. arr3.push(item)
  823. arr4.push(item.id)
  824. }
  825. })
  826. if (arr3.length > 0) {} else {
  827. this.$message({
  828. message: '请选择已签收的运单',
  829. type: 'warning'
  830. });
  831. }
  832. } else {
  833. this.$message({
  834. message: '请先选择需要批量操作的运单',
  835. type: 'warning'
  836. });
  837. }
  838. }
  839. },
  840. // 导入
  841. immediateImport() {
  842. if (this.importFile) {
  843. this.importFlag = true
  844. let formData = new FormData();
  845. formData.append('file', this.importFile);
  846. waybillImport(formData).then(res => {
  847. if (res.code == 200) {
  848. this.bulkImportVisible = false
  849. this.importFlag = false
  850. this.getList()
  851. this.$message({
  852. message: '恭喜你,导入成功',
  853. type: 'success'
  854. });
  855. }
  856. })
  857. } else {
  858. this.$message({
  859. message: '请先选择上传文件',
  860. type: 'warning'
  861. });
  862. }
  863. },
  864. // 导出模板
  865. templateDownload() {
  866. this.downloadFlag = true
  867. exportTemplate().then(response => {
  868. if (response.fileName) {
  869. this.blobDownload(response.data, response.fileName)
  870. }
  871. this.downloadFlag = false
  872. })
  873. },
  874. // 上传文件
  875. UploadImage(param) {
  876. this.importFile = param.file
  877. },
  878. // 导出文件流
  879. blobDownload(data, name) {
  880. let m = this;
  881. var content = data;
  882. var data = new Blob([content], {
  883. type: "application/vnd.ms-excel;charset=utf-8"
  884. });
  885. var downloadUrl = window.URL.createObjectURL(data);
  886. var anchor = document.createElement("a");
  887. anchor.href = downloadUrl;
  888. anchor.download = decodeURIComponent(name);
  889. anchor.click();
  890. window.URL.revokeObjectURL(data);
  891. },
  892. changeSize(val) {
  893. this.Pagination.PageSize = val
  894. this.getList()
  895. },
  896. changeCurrent(val) {
  897. this.Pagination.PageIndex = val
  898. this.getList()
  899. },
  900. // 地址簿
  901. bookChangeSize(val) {
  902. this.bookPagination.PageSize = val
  903. if (this.bookType == 'deliverer') {
  904. this.getDelivererList()
  905. } else {
  906. this.getSenderSend()
  907. }
  908. },
  909. bookChangeCurrent(val) {
  910. this.bookPagination.PageIndex = val
  911. if (this.bookType == 'deliverer') {
  912. this.getDelivererList()
  913. } else {
  914. this.getSenderSend()
  915. }
  916. },
  917. // 快速搜索
  918. fastSearch() {
  919. this.bookPagination.PageIndex = 1
  920. if (this.bookType == 'deliverer') {
  921. this.getDelivererList()
  922. }
  923. },
  924. // 清空表单
  925. closeDialog() {
  926. this.$refs.sendRules.resetCheck();
  927. },
  928. // 清空表单
  929. closeDialog1() {
  930. this.$refs.signRules.resetCheck();
  931. },
  932. // 清空表单
  933. closeDialog2() {
  934. this.$refs.mYupload.clearFiles();
  935. },
  936. // 关闭清空表单
  937. closePopup() {
  938. this.ruleForm.fileList = []
  939. // this.$refs.sender.resetForm()
  940. this.$refs.recipients.resetForm()
  941. // this.$refs.deliverer.resetForm()
  942. this.$refs.childRules.resetCheck()
  943. this.$refs.userRules.resetCheck()
  944. this.personnelList.forEach(item => {
  945. item.options = []
  946. })
  947. }
  948. }
  949. }
  950. </script>
  951. <style lang="scss" scoped>
  952. ::v-deep .el-dialog {
  953. margin: 0 auto !important;
  954. margin-top: 7vh !important;
  955. }
  956. .waybill_home ::v-deep .el-dialog__header {
  957. border-bottom: 1px solid #E4E7ED;
  958. }
  959. .waybill_home ::v-deep .el-dialog__body {
  960. padding: 10px 20px 30px 20px;
  961. }
  962. .waybil_form ::v-deep .el-cascader {
  963. width: 100% !important;
  964. }
  965. .card_waybill {
  966. display: flex;
  967. flex-direction: column;
  968. border-bottom: 1px solid #E4E7ED;
  969. }
  970. .waybill_item {
  971. width: 100%;
  972. }
  973. .card_book_list {
  974. border: 1px solid #DCDFE6;
  975. }
  976. .card_bulkImport {
  977. width: 100%;
  978. }
  979. ::v-deep .el-upload {
  980. width: 100%;
  981. }
  982. ::v-deep .el-upload-dragger {
  983. width: 100%;
  984. }
  985. .card_customer {
  986. display: flex;
  987. align-items: center;
  988. margin-bottom: 15px;
  989. span {
  990. flex: none;
  991. font-size: 15px;
  992. margin-right: 8px;
  993. }
  994. }
  995. </style>