WaybillManagement.vue 29 KB

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