orderOperation.blade.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <script>
  2. Vue.component('orderOperation', {
  3. props: {
  4. operationType:{
  5. type:Number|String,
  6. default:'',
  7. },
  8. operationOrder:{
  9. type:Object|String,
  10. default:{},
  11. },
  12. synchro:{
  13. type:Number|String,
  14. default:0,
  15. },
  16. expressCompanies:{
  17. type:Array|Object,
  18. default:[],
  19. },
  20. dialog_show:{
  21. type:Number,
  22. default:0,
  23. },
  24. pay_skip:{
  25. type:Number,
  26. default:0,
  27. },
  28. },
  29. delimiters: ['[[', ']]'],
  30. data(){
  31. return{
  32. url_open : "{!! yzWebUrl('order.waybill.waybill') !!}",
  33. readonly:false,
  34. cancel_send_show:false,// 取消发货弹窗
  35. cancel_send_con:"",//取消发货原因
  36. cancel_send_id:'',
  37. confirm_send_show:false,// 确认发货弹窗
  38. confirm_send_id:"",
  39. address_info:{},
  40. //发货提交信息
  41. send:{
  42. dispatch_type_id:1,
  43. express_code:"",
  44. express_sn:"",
  45. },
  46. send_rules:{
  47. },
  48. // 多包裹发货
  49. more_send_show:false,
  50. order_goods_send_list:[],
  51. order_goods_send_list2:[],// 临时
  52. send_order_goods_ids:[],
  53. readonly:false,
  54. web_url: "{!! yzWebUrl('') !!}",
  55. }
  56. },
  57. watch:{
  58. dialog_show(val) {
  59. if (this.operationType == 1) {
  60. this.confirmPay(this.operationOrder.id);
  61. } else if (this.operationType == 2) {
  62. this.confirmSend(this.operationOrder.id, this.operationOrder);
  63. } else if (this.operationType == 3) {
  64. this.confirmReceive(this.operationOrder.id);
  65. } else if (this.operationType == 'cancel_send') {
  66. this.cancelSend(this.operationOrder.id);
  67. } else if (this.operationType == 'separate_send') {
  68. this.separateSend(this.operationOrder.id, this.operationOrder);
  69. } else if (this.operationType == 'city_delivery_push') {
  70. this.cityDeliveryPush(this.operationOrder);
  71. } else if (this.operationType == 'city_delivery_cancel') {
  72. this.cityDeliveryCancel(this.operationOrder);
  73. } else if (this.operationType == 'city_delivery_refresh') {
  74. this.cityDeliveryRefresh(this.operationOrder);
  75. } else if (this.operationType == 'public_request') {
  76. this.public_request(this.operationOrder);
  77. }
  78. },
  79. },
  80. mounted: function(){
  81. },
  82. methods:{
  83. public_request(order) {
  84. let operationType = this.operationType;
  85. let obj = this.operationOrder.backend_button_models.find(item => {
  86. return item.value == operationType;
  87. });
  88. let loading = this.$loading({target: document.querySelector(".content"), background: 'rgba(0, 0, 0, 0)'});
  89. this.$http.post(this.web_url + obj.api, {order_id: order.id}).then(function (response) {
  90. if (response.data.result) {
  91. this.$message({type: 'success', message: response.data.msg});
  92. location.reload();
  93. } else {
  94. this.$message({type: 'error', message: response.data.msg});
  95. }
  96. loading.close();
  97. this.$emit('search');
  98. }, function (response) {
  99. this.$message({type: 'error', message: response.data.msg});
  100. loading.close();
  101. }
  102. );
  103. },
  104. cityDeliveryRefresh(order) {
  105. let obj = this.operationOrder.backend_button_models.find(item => {
  106. return item.value == 'city_delivery_refresh'
  107. });
  108. let loading = this.$loading({target: document.querySelector(".content"), background: 'rgba(0, 0, 0, 0)'});
  109. this.$http.post(this.web_url + obj.api, {order_id: order.id}).then(function (response) {
  110. if (response.data.result) {
  111. this.$message({type: 'success', message: '操作成功'});
  112. location.reload();
  113. } else {
  114. this.$message({type: 'error', message: response.data.msg});
  115. }
  116. loading.close();
  117. this.$emit('search');
  118. }, function (response) {
  119. this.$message({type: 'error', message: response.data.msg});
  120. loading.close();
  121. }
  122. );
  123. },
  124. cityDeliveryCancel(order){
  125. let obj = this.operationOrder.backend_button_models.find(item => {
  126. return item.value == 'city_delivery_cancel'
  127. });
  128. this.$confirm('确定取消第三方订单吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  129. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  130. this.$http.post(this.web_url+obj.api,{order_id:order.id}).then(function (response) {
  131. if (response.data.result) {
  132. this.$message({type: 'success',message: '操作成功'});
  133. location.reload();
  134. }
  135. else{
  136. this.$message({type: 'error',message: response.data.msg});
  137. }
  138. loading.close();
  139. this.$emit('search');
  140. },function (response) {
  141. this.$message({type: 'error',message: response.data.msg});
  142. loading.close();
  143. }
  144. );
  145. }).catch(() => {
  146. this.$message({type: 'info',message: '已取消操作'});
  147. });
  148. },
  149. //同城配送推送订单到第三方
  150. cityDeliveryPush(order){
  151. let obj = this.operationOrder.backend_button_models.find(item => {
  152. return item.value == 'city_delivery_push'
  153. });
  154. this.$confirm('确定推送此订单到第三方吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  155. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  156. this.$http.post(this.web_url+obj.api,{order_id:order.id}).then(function (response) {
  157. if (response.data.result) {
  158. this.$message({type: 'success',message: '操作成功'});
  159. location.reload();
  160. }
  161. else{
  162. this.$message({type: 'error',message: response.data.msg});
  163. }
  164. loading.close();
  165. this.$emit('search');
  166. },function (response) {
  167. this.$message({type: 'error',message: response.data.msg});
  168. loading.close();
  169. }
  170. );
  171. }).catch(() => {
  172. this.$message({type: 'info',message: '已取消操作'});
  173. });
  174. },
  175. // 确认付款
  176. confirmPay(id) {
  177. let obj = this.operationOrder.backend_button_models.find(item => {
  178. return item.value == 1
  179. });
  180. this.$confirm('确认此订单已付款吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  181. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  182. this.$http.post(this.web_url+obj.api,{order_id:id}).then(function (response) {
  183. if (response.data.result) {
  184. this.$message({type: 'success',message: '操作成功'});
  185. if(this.pay_skip == 1) {
  186. location.reload();
  187. }
  188. }
  189. else{
  190. this.$message({type: 'error',message: response.data.msg});
  191. }
  192. loading.close();
  193. this.$emit('search');
  194. },function (response) {
  195. this.$message({type: 'error',message: response.data.msg});
  196. loading.close();
  197. }
  198. );
  199. }).catch(() => {
  200. this.$message({type: 'info',message: '已取消操作'});
  201. });
  202. },
  203. // 取消发货
  204. cancelSend(id) {
  205. this.cancel_send_show = true;
  206. this.cancel_send_con = "";
  207. this.cancel_send_id = id;
  208. // console.log(id)
  209. },
  210. // 确认取消发货
  211. sureCancelSend() {
  212. let json = {
  213. // route:'order.operation.manualRefund',
  214. order_id:this.cancel_send_id,
  215. cancelreson:this.cancel_send_con,
  216. };
  217. let obj = this.operationOrder.backend_button_models.find(item => {
  218. return item.value == 'cancel_send'
  219. })
  220. // console.log(json);
  221. let loading = this.$loading({target:document.querySelector("#cancel-send"),background: 'rgba(0, 0, 0, 0)'});
  222. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  223. if (response.data.result) {
  224. this.$message({type: 'success',message: '取消发货成功!'});
  225. }
  226. else{
  227. this.$message({type: 'error',message: response.data.msg});
  228. }
  229. loading.close();
  230. this.close_order_show = false;
  231. this.$emit('search');
  232. },function (response) {
  233. this.$message({type: 'error',message: response.data.msg});
  234. loading.close();
  235. this.close_order_show = false;
  236. })
  237. },
  238. // 确认收货
  239. confirmReceive(id) {
  240. let obj = this.operationOrder.backend_button_models.find(item => {
  241. return item.value == 3
  242. })
  243. this.$confirm('确认订单收货吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {
  244. let loading = this.$loading({target:document.querySelector(".content"),background: 'rgba(0, 0, 0, 0)'});
  245. this.$http.post(this.web_url+obj.api,{order_id:id}).then(function (response) {
  246. if (response.data.result) {
  247. this.$message({type: 'success',message: '操作成功'});
  248. }
  249. else{
  250. this.$message({type: 'error',message: response.data.msg});
  251. }
  252. loading.close();
  253. this.$emit('search');
  254. },function (response) {
  255. this.$message({type: 'error',message: response.data.msg});
  256. loading.close();
  257. }
  258. );
  259. }).catch(() => {
  260. this.$message({type: 'info',message: '已取消操作'});
  261. });
  262. },
  263. // 确认发货
  264. async confirmSend(id,item) {
  265. let synchro = this.getSessionStore('synchro');
  266. if (!synchro) {
  267. synchro =await this.$http.post("{!! yzWebUrl('order.order-list.get-synchro') !!}").then(({ data:{ data } })=>{
  268. this.setSessionStore('synchro',data);
  269. return data;
  270. })
  271. }
  272. this.readonly = false;
  273. if (synchro){
  274. this.$http.post(this.url_open,{id:id}).then(function (response) {
  275. if (response.data.result && response.data.result != 'error') {
  276. this.send.express_code = response.data.resp.shipper_code;
  277. this.send.express_sn = response.data.resp.logistic_code;
  278. this.readonly = true;
  279. }
  280. },function (response) {
  281. this.$message({type: 'error',message: response.data.msg});
  282. }
  283. );
  284. }
  285. this.confirm_send_show = true;
  286. this.confirm_send_con = "";
  287. this.send = {
  288. dispatch_type_id :1,
  289. express_code:"",
  290. express_sn:""
  291. }
  292. this.confirm_send_id = id;
  293. this.address_info = item.address || {};
  294. },
  295. setSessionStore (name, content) {
  296. if (!name) return
  297. // if (typeof content !== 'string') {
  298. // content = JSON.stringify(content)
  299. // }
  300. window.sessionStorage.setItem(name, content)
  301. },
  302. getSessionStore (name) {
  303. if (!name) return;
  304. var content = window.sessionStorage.getItem(name);
  305. // if (typeof content == 'string') {
  306. // content = JSON.parse(content)
  307. // }
  308. return content;
  309. },
  310. // 确认确认发货
  311. sureconfirmSend() {
  312. let json = {
  313. dispatch_type_id:this.send.dispatch_type_id,
  314. express_code:this.send.express_code,
  315. express_sn:this.send.express_sn,
  316. order_id:this.confirm_send_id,
  317. };
  318. let obj = this.operationOrder.backend_button_models.find(item => {
  319. return item.value == 2
  320. })
  321. // console.log(obj);
  322. // console.log(json);
  323. // if(this.send.express_sn == "") {
  324. // this.$message.error("快递单号不能为空!");
  325. // return;
  326. // }
  327. let loading = this.$loading({target:document.querySelector("#cancel-send"),background: 'rgba(0, 0, 0, 0)'});
  328. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  329. if (response.data.result) {
  330. this.$message({type: 'success',message: '确认发货成功!'});
  331. }
  332. else{
  333. this.$message({type: 'error',message: response.data.msg});
  334. }
  335. loading.close();
  336. this.confirm_send_show = false;
  337. this.$emit('search');
  338. },function (response) {
  339. this.$message({type: 'error',message: response.data.msg});
  340. loading.close();
  341. this.confirm_send_show = false;
  342. })
  343. },
  344. //多包裹发货
  345. separateSend(id,item) {
  346. this.more_send_show = true;
  347. this.confirm_send_id = id;
  348. this.send = {
  349. dispatch_type_id :1,
  350. express_code:"",
  351. express_sn:"",
  352. };
  353. this.address_info = item.address || {};
  354. this.getSeparateSendOrderGoods(id);
  355. },
  356. // 多包裹确认发货 选择商品
  357. moreSendChange(selection) {
  358. let arr = [];
  359. for (let value of selection){
  360. arr.push(value.id);
  361. }
  362. this.send_order_goods_ids = arr;
  363. },
  364. getOneOrderPackage()
  365. {
  366. let arr = [];
  367. for (let value of this.send_order_goods_ids){
  368. for (let item of this.order_goods_send_list2){
  369. if(item.id == value){
  370. arr.push({
  371. order_goods_id:value,
  372. total:item.total
  373. });
  374. }
  375. }
  376. }
  377. return arr ? arr : [];
  378. },
  379. // 获取可选择的商品 多包裹发货
  380. getSeparateSendOrderGoods(id) {
  381. this.$http.post('{!! yzWebFullUrl('order.multiple-packages-order-goods.get-order-goods') !!}', {order_id:id}).then(function (response) {
  382. if (response.data.result) {
  383. this.order_goods_send_list = response.data.data;
  384. this.order_goods_send_list2 = JSON.parse(JSON.stringify(response.data.data));
  385. } else{
  386. this.$message({type: 'error',message: response.data.msg});
  387. }
  388. },function (response) {
  389. this.$message({type: 'error',message: response.data.msg});
  390. });
  391. },
  392. //多包裹确认发货
  393. confirmMoreSend() {
  394. if(this.send_order_goods_ids == undefined || this.send_order_goods_ids.length <= 0) {
  395. this.$message.error("请选择分批发货订单商品!");
  396. return;
  397. }
  398. if(this.send.express_sn == "") {
  399. this.$message.error("快递单号不能为空!");
  400. return;
  401. }
  402. let json = {
  403. dispatch_type_id:this.send.dispatch_type_id,
  404. express_code:this.send.express_code,
  405. express_sn:this.send.express_sn,
  406. order_id:this.confirm_send_id,
  407. order_goods_ids:this.send_order_goods_ids,
  408. order_package:this.getOneOrderPackage()
  409. };
  410. // console.log(json);
  411. let obj = this.operationOrder.backend_button_models.find(item => {
  412. return item.value == 'separate_send'
  413. })
  414. // console.log(obj.api)
  415. let loading = this.$loading({target:document.querySelector("#separate-send"),background: 'rgba(0, 0, 0, 0)'});
  416. this.$http.post(this.web_url+obj.api,json).then(function (response) {
  417. if (response.data.result) {
  418. this.$message({type: 'success',message: '发货成功!'});
  419. } else{
  420. this.$message({type: 'error',message: response.data.msg});
  421. }
  422. loading.close();
  423. this.more_send_show = false;
  424. location.reload(); //刷新页面
  425. },function (response) {
  426. this.$message({type: 'error',message: response.data.msg});
  427. loading.close();
  428. this.more_send_show = false;
  429. })
  430. },
  431. },
  432. template: `
  433. <div>
  434. <!-- 取消发货 -->
  435. <el-dialog :visible.sync="cancel_send_show" width="750px" title="取消发货">
  436. <div style="height:300px;overflow:auto" id="cancel-send">
  437. <div style="color:#000;font-weight:500">取消发货原因</div>
  438. <el-input v-model="cancel_send_con" :rows="10" type="textarea"></el-input>
  439. </div>
  440. <span slot="footer" class="dialog-footer">
  441. <el-button @click="cancel_send_show = false">取 消</el-button>
  442. <el-button type="primary" @click="sureCancelSend">取消发货 </el-button>
  443. </span>
  444. </el-dialog>
  445. <!-- 确认发货 -->
  446. <el-dialog :visible.sync="confirm_send_show" width="750px" title="确认发货">
  447. <div style="height:400px;overflow:auto" id="confirm-send">
  448. <el-form ref="send" :model="send" :rules="send_rules" label-width="15%">
  449. <el-form-item label="收件人信息" prop="aggregation">
  450. <div>收 件 人: [[address_info.realname]] / [[address_info.mobile]]</div>
  451. <div>收货地址: [[address_info.address]]</div>
  452. </el-form-item>
  453. <el-form-item label="配送方式" prop="">
  454. <el-radio v-model="send.dispatch_type_id" :label="1">快递</el-radio>
  455. </el-form-item>
  456. <el-form-item label="快递公司">
  457. <el-select v-model="send.express_code" clearable filterable placeholder="快递公司" :disabled='readonly' style="width:70%;">
  458. <el-option label="其他快递" value=""></el-option>
  459. <el-option v-for="(item,index) in expressCompanies" :key="index" :label="item.name" :value="item.value"></el-option>
  460. </el-select>
  461. </el-form-item>
  462. <el-form-item label="快递单号" prop="">
  463. <el-input v-model="send.express_sn" :disabled='readonly' style="width:70%;"></el-input>
  464. </el-form-item>
  465. </el-form>
  466. </div>
  467. <span slot="footer" class="dialog-footer">
  468. <el-button @click="confirm_send_show = false">取 消</el-button>
  469. <el-button type="primary" @click="sureconfirmSend()">确认发货 </el-button>
  470. </span>
  471. </el-dialog>
  472. <!-- 多包裹确认发货 -->
  473. <el-dialog :visible.sync="more_send_show" width="750px" title="分批发货">
  474. <div style="" id="separate-send">
  475. <el-form ref="send" :model="send" label-width="15%">
  476. <el-form-item label="收件人信息" prop="aggregation">
  477. <div>收 件 人: [[address_info.realname]] / [[address_info.mobile]]</div>
  478. <div>收货地址: [[address_info.address]]</div>
  479. </el-form-item>
  480. <el-form-item label="快递公司">
  481. <el-select v-model="send.express_code" clearable filterable placeholder="快递公司" style="width:70%;">
  482. <el-option label="其他快递" value=""></el-option>
  483. <el-option v-for="(v1,k1) in expressCompanies" :key="k1" :label="v1.name" :value="v1.value"></el-option>
  484. </el-select>
  485. </el-form-item>
  486. <el-form-item label="快递单号" prop="">
  487. <el-input v-model="send.express_sn" style="width:70%;"></el-input>
  488. </el-form-item>
  489. </el-form>
  490. <el-table ref="multipleTable" :data="order_goods_send_list" tooltip-effect="dark" height="250" style="width: 100%" @selection-change="moreSendChange">
  491. <el-table-column type="selection" width="55"></el-table-column>
  492. <el-table-column width="550">
  493. <template slot-scope="scope">
  494. <div style="display:flex;">
  495. <div style="display:flex;flex:1;">
  496. <div style="width:50px;height:50px">
  497. <img :src="scope.row.thumb" alt="" style="width:50px;height:50px">
  498. </div>
  499. <div style="margin:0 20px;display: flex;flex-direction: column;justify-content: space-between;">
  500. <div style="display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:5;overflow: hidden;text-overflow: ellipsis;">[[scope.row.title]]</div>
  501. <div style="color:#999">[[scope.row.goods_id]]</div>
  502. </div>
  503. </div>
  504. <div>
  505. <el-input-number size="small" controls-position="right" v-model="order_goods_send_list2[scope.$index].total" :min="1" :max="scope.row.total" label="数量"></el-input-number>
  506. <div style="color:#999">最大数量999 * [[scope.row.total]]</div>
  507. </div>
  508. </div>
  509. </template>
  510. </el-table-column>
  511. <el-table-column>
  512. <template slot-scope="scope">
  513. <div style="color:#999">[[scope.row.goods_option_title]]</div>
  514. </template>
  515. </el-table-column>
  516. </el-table>
  517. </div>
  518. <span slot="footer" class="dialog-footer">
  519. <el-button @click="more_send_show = false">取 消</el-button>
  520. <el-button type="primary" @click="confirmMoreSend()">确认发货 </el-button>
  521. </span>
  522. </el-dialog>
  523. </div>
  524. `,
  525. });
  526. </script>