order.blade.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template id="electronicsBill">
  2. <div>
  3. <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0"
  4. height="0">
  5. <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0" pluginspage="{{resource_get('plugins/electronics-bill/src/common/lodop/install_lodop32.exe', 1)}}"></embed>
  6. </object>
  7. {{--不知道这段有什么用暂时注释--}}
  8. {{-- <div style="margin-right: 15px;color: #909399;float: left">--}}
  9. {{-- <span v-if="item && item.has_many_bill_temp != false">--}}
  10. {{-- 已打印--}}
  11. {{-- </span>--}}
  12. {{-- <span v-else>--}}
  13. {{-- 未打印--}}
  14. {{-- </span>--}}
  15. {{-- </div>--}}
  16. <div style="margin-right: 15px;float: left" v-if="item && item.has_many_bill_temp.length == 0">
  17. <el-dropdown trigger="click" @command="buttonPrint">
  18. <span class="el-dropdown-link" style="color:#29BA9C">打印电子面单</span>
  19. <el-dropdown-menu slot="dropdown">
  20. <el-dropdown-item :command="{type:'one_print',order_id:item.id}">单包裹打印</el-dropdown-item>
  21. <el-dropdown-item :command="{type:'open_package_view',order_id:item.id}">多包裹打印</el-dropdown-item>
  22. </el-dropdown-menu>
  23. </el-dropdown>
  24. </div>
  25. <div style="margin-right: 15px;float: left" v-if="item && item.has_many_bill_temp.length != 0">
  26. <el-dropdown trigger="click" @command="buttonPrint">
  27. <span class="el-dropdown-link" style="color:#29BA9C">打印电子面单</span>
  28. <el-dropdown-menu slot="dropdown">
  29. <el-dropdown-item :command="{type:'old_print',order_id:item.id}">原单号打印</el-dropdown-item>
  30. <el-dropdown-item :command="{type:'one_print',order_id:item.id,new_print:1}" v-if="item.status == 1 || item.status == 2">新单号打印</el-dropdown-item>
  31. <el-dropdown-item :command="{type:'open_package_view',order_id:item.id}" v-if="item.status == 1 || item.status == 2">多包裹打印</el-dropdown-item>
  32. </el-dropdown-menu>
  33. </el-dropdown>
  34. </div>
  35. <el-dialog
  36. title="多包裹打印"
  37. :visible.sync="package_view"
  38. width="40%"
  39. :before-close="closePackageView"
  40. >
  41. <a style="color:#29BA9C" @click="openGoodsView()">+创建包裹</a>
  42. <span style="margin-left: 15px">还剩[[statisticsGoodsNum()]]件商品未分配</span>
  43. <el-tabs type="card">
  44. <el-tab-pane v-for="(item,index) in package">
  45. <span slot="label">
  46. <span>包裹[[index + 1]]</span>
  47. <a @click="delPackage(index)">×</a>
  48. </span>
  49. <div>
  50. <span>共[[statisticsPackageGoodsNum(index)]]件商品</span>
  51. <a style="color:#29BA9C" @click="openGoodsView(index)">+添加商品</a>
  52. </div>
  53. <el-table :data="item" style="width: 100%">
  54. <el-table-column>
  55. <template slot-scope="scope">
  56. <el-image :src="scope.row.thumb"></el-image>
  57. </template>
  58. </el-table-column>
  59. <el-table-column>
  60. <template slot-scope="scope">
  61. <span>[[scope.row.title]]</span>
  62. <span>[[scope.row.goods_id]]</span>
  63. </template>
  64. </el-table-column>
  65. <el-table-column>
  66. <template slot-scope="scope">
  67. <span>[[scope.row.goods_option_title]]</span>
  68. <el-popover
  69. placement="top-end"
  70. width="200"
  71. trigger="click">
  72. <div style="text-align: center">
  73. <el-input-number v-model="scope.row.total" :min="1"
  74. size="mini"></el-input-number>
  75. <br>
  76. <span>剩余数量[[statisticsGoodsNum(scope.row.id)]]</span>
  77. <el-button type="primary" size="mini" @click="filterGoods()">确定
  78. </el-button>
  79. </div>
  80. <el-link title="编辑" :underline="false" slot="reference">
  81. <i class="el-icon-edit"></i>
  82. </el-link>
  83. </el-popover>
  84. <span>×[[scope.row.total]]</span>
  85. </template>
  86. </el-table-column>
  87. <el-table-column>
  88. <template slot-scope="scope">
  89. <el-link title="删除" @click="delGoods(index,scope.$index)">
  90. <i class="el-icon-delete"></i>
  91. </el-link>
  92. </template>
  93. </el-table-column>
  94. </el-table>
  95. </el-tab-pane>
  96. </el-tabs>
  97. <span slot="footer" class="dialog-footer">
  98. <el-button type="primary" @click="printMore()">打印</el-button>
  99. </span>
  100. </el-dialog>
  101. <el-dialog
  102. title="选择商品"
  103. :visible.sync="goods_view"
  104. width="50%"
  105. :before-close="handleClose"
  106. >
  107. <el-table :data="surplus_goods" ref="selectOrderGoods" @selection-change="handleSelectionChange">
  108. <el-table-column type="selection"></el-table-column>
  109. <el-table-column width="100px" :label="'共' + statisticsGoodsNum() + '件商品'">
  110. <template slot-scope="scope">
  111. <el-image :src="scope.row.thumb"></el-image>
  112. </template>
  113. </el-table-column>
  114. <el-table-column>
  115. <template slot-scope="scope">
  116. <div style="text-align: left">
  117. <span>[[scope.row.title]]</span>
  118. <br>
  119. <span>[[scope.row.goods_id]]</span>
  120. </div>
  121. </template>
  122. </el-table-column>
  123. <el-table-column>
  124. <template slot-scope="scope">
  125. <div style="text-align: right;margin-right: 15px">
  126. <span style="margin-right: 10px">[[scope.row.goods_option_title ? scope.row.goods_option_title : '默认']]</span>
  127. <el-popover
  128. placement="top-end"
  129. width="200"
  130. trigger="click">
  131. <div style="text-align: center">
  132. <el-input-number v-model="scope.row.total" :min="0" :max="scope.row.size_num"
  133. size="mini"></el-input-number>
  134. <br>
  135. <span>剩余数量[[scope.row.size_num]]</span>
  136. </div>
  137. <el-link title="编辑" :underline="false" slot="reference">
  138. <i class="el-icon-edit"></i>
  139. </el-link>
  140. </el-popover>
  141. <span>×[[scope.row.total]]</span>
  142. </div>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. <span slot="footer" class="dialog-footer">
  147. <el-button type="primary" @click="createPackage()" v-if="!goods_view2">创建</el-button>
  148. <el-button type="primary" @click="addGoods()" v-if="goods_view2">添加</el-button>
  149. </span>
  150. </el-dialog>
  151. </div>
  152. </template>
  153. <script src="{{resource_get('plugins/electronics-bill/src/common/static/js/LodopFuncs.js', 1)}}"></script>
  154. <script src="{{resource_get('plugins/electronics-bill/src/common/static/js/jquery.jqprint-0.3.js')}}"></script>
  155. <script src="{{resource_get('plugins/electronics-bill/src/common/static/js/jquery-migrate-1.2.1.min.js')}}"></script>
  156. <script>
  157. Vue.component('electronicsBill', {
  158. props: {item:{
  159. type:Object,
  160. default:()=>{}
  161. }},
  162. delimiters: ['[[', ']]'],
  163. data() {
  164. return {
  165. get_goods_url: '{!! yzWebFullUrl('plugin.electronics-bill.admin.order-package.getGoods') !!}',// 获取剩余商品
  166. get_template_url: '{!! yzWebFullUrl('plugin.electronics-bill.admin.order-package.getOriginallyTemplate') !!}',// 原单号打印
  167. print_one_package_url: '{!! yzWebFullUrl('plugin.electronics-bill.admin.order-package.printOnePackage') !!}',// 单包裹打印
  168. print_more_package_url: '{!! yzWebFullUrl('plugin.electronics-bill.admin.order-package.printMorePackage') !!}',// 多包裹打印
  169. order_id:0,
  170. order_goods: [],// 订单商品
  171. template_list: [],// 打印模板
  172. package: [],// 包裹
  173. surplus_goods: [],
  174. select_change: [],
  175. goods_view: false,
  176. package_view: false,
  177. goods_view2:false,
  178. package_index:0,
  179. }
  180. },
  181. watch: {
  182. },
  183. mounted: function () {
  184. // console.log(this.item);
  185. },
  186. methods: {
  187. buttonPrint(param){
  188. switch (param.type){
  189. case 'open_package_view':// 多包裹打印
  190. this.openPackageView(param.order_id);
  191. this.getGoods(param.order_id);
  192. break;
  193. case 'old_print':// 原单号打印
  194. this.getTemplate(param.order_id);
  195. break;
  196. case 'one_print':// 新单号打印
  197. if(param.new_print) {
  198. this.$confirm('此按钮相当于重新单包裹发货,确定吗?')
  199. .then(_ => {
  200. this.printOnePackage(param.order_id);
  201. })
  202. .catch(_ => {
  203. });
  204. }else{
  205. this.printOnePackage(param.order_id);
  206. }
  207. break;
  208. }
  209. },
  210. // 打印
  211. printMore(){
  212. this.printMorePackage(this.order_id,this.handleMorePackage());
  213. },
  214. // 获取未发货的商品
  215. getGoods(order_id) {
  216. let that = this;
  217. let url = that.get_goods_url + '&order_id=' + order_id;
  218. let loading = that.$loading({
  219. target: document.querySelector(".content"),
  220. background: 'rgba(0, 0, 0, 0)'
  221. });
  222. that.$http.get(url).then((res) => {
  223. if (res.data.result == 1) {
  224. that.order_goods = res.data.data;
  225. this.filterGoods()
  226. } else {
  227. that.$message({message: res.data.msg, type: 'error'});
  228. }
  229. loading.close();
  230. }, (err) => {
  231. that.$message({message: err.data.msg, type: 'error'});
  232. loading.close();
  233. })
  234. },
  235. // 获取原单号
  236. getTemplate(order_id) {
  237. let that = this;
  238. let url = that.get_template_url + '&order_id=' + order_id;
  239. let loading = that.$loading({
  240. target: document.querySelector(".content"),
  241. background: 'rgba(0, 0, 0, 0)'
  242. });
  243. that.$http.get(url).then((res) => {
  244. if (res.data.result == 1) {
  245. that.template_list = res.data.data.template_list;
  246. this.billTempView(that.template_list);
  247. } else {
  248. that.$message({message: res.data.msg, type: 'error'});
  249. }
  250. loading.close();
  251. }, (err) => {
  252. that.$message({message: err.data.msg, type: 'error'});
  253. loading.close();
  254. })
  255. },
  256. // 单包裹打印
  257. printOnePackage(order_id) {
  258. let that = this;
  259. let url = that.print_one_package_url;
  260. let loading = that.$loading({
  261. target: document.querySelector(".content"),
  262. background: 'rgba(0, 0, 0, 0)'
  263. });
  264. that.$http.post(url, {order_id: order_id}).then((res) => {
  265. if (res.data.result == 1) {
  266. that.template_list = res.data.data.template_list;
  267. this.billTempView(that.template_list);
  268. } else {
  269. that.$message({message: res.data.msg, type: 'error'});
  270. }
  271. loading.close();
  272. }, (err) => {
  273. that.$message({message: err.data.msg, type: 'error'});
  274. loading.close();
  275. })
  276. },
  277. // 多包裹打印
  278. printMorePackage(order_id, package) {
  279. let that = this;
  280. let url = that.print_more_package_url;
  281. let loading = that.$loading({
  282. target: document.querySelector(".content"),
  283. background: 'rgba(0, 0, 0, 0)'
  284. });
  285. that.$http.post(url, {order_id: order_id, order_package: package}).then((res) => {
  286. if (res.data.result == 1) {
  287. that.template_list = res.data.data.template_list;
  288. this.billTempView(that.template_list);
  289. } else {
  290. that.$message({message: res.data.msg, type: 'error'});
  291. }
  292. loading.close();
  293. }, (err) => {
  294. that.$message({message: err.data.msg, type: 'error'});
  295. loading.close();
  296. })
  297. },
  298. // 处理多包裹请求
  299. handleMorePackage(){
  300. let order_package = [];
  301. for (let item of this.package){
  302. let goods_list = [];
  303. for(let item2 of item){
  304. goods_list.push({
  305. order_goods_id:item2.id,
  306. total:item2.total,
  307. });
  308. }
  309. order_package.push(goods_list);
  310. }
  311. return order_package;
  312. },
  313. // 过滤剩余商品
  314. filterGoods() {
  315. let goods_list = JSON.parse(JSON.stringify(this.order_goods));
  316. if (this.package.length != 0) {
  317. for (let v1 of this.package) {
  318. for (let v2 of v1) {
  319. let goods_list2 = goods_list.filter(item => {
  320. if (item.id == v2.order_goods_id) {
  321. item.total -= v2.total;
  322. if (item.total <= 0) {
  323. return false;
  324. }
  325. }
  326. return true;
  327. });
  328. goods_list = goods_list2;
  329. }
  330. }
  331. }
  332. for (let v1 of goods_list) {
  333. this.$set(v1, 'size_num', v1.total)
  334. this.$set(v1, 'order_goods_id', v1.id)
  335. }
  336. // console.log(goods_list);
  337. this.surplus_goods = goods_list;
  338. },
  339. // 打印
  340. billTempView(template) {
  341. let newWin = window.open("")
  342. template.forEach((item,i) => {
  343. let tempList = item.print_template;
  344. newWin.document.write(tempList); //将需要打印的内容添加进新的窗口
  345. })
  346. newWin.document.close(); //在IE浏览器中使用必须添加这一句
  347. newWin.focus(); //在IE浏览器中使用必须添加这一句
  348. setTimeout(function () {
  349. newWin.print(); //打印
  350. newWin.close(); //关闭窗口
  351. }, 100);
  352. },
  353. // 打开包裹视图
  354. openPackageView(order_id) {
  355. this.order_id = order_id
  356. this.package_view = true;
  357. },
  358. // 打开商品视图
  359. openGoodsView(package_index) {
  360. if(package_index === 0 || package_index){
  361. this.goods_view2 = true;
  362. this.package_index = package_index;
  363. console.log(this.goods_view2,this.package_index);
  364. }
  365. this.filterGoods();
  366. this.goods_view = true;
  367. },
  368. // 创建包裹
  369. createPackage() {
  370. let package = [];
  371. for (let item of this.select_change) {
  372. if (item.total <= 0) continue;
  373. for (let item2 of this.surplus_goods){
  374. if(item.id == item2.id){
  375. package.push(JSON.parse(JSON.stringify(item2)));
  376. }
  377. }
  378. }
  379. if(package.length > 0){
  380. this.package.push(package);
  381. }
  382. this.filterGoods();
  383. this.goods_view = false;
  384. },
  385. // 删除包裹
  386. delPackage(index) {
  387. this.package.splice(index, 1);
  388. this.filterGoods();
  389. },
  390. // 添加商品
  391. addGoods(){
  392. // console.log(this.package_index,this.package[this.package_index]);
  393. // return;
  394. for (let item of this.select_change) {
  395. if(item.total <= 0) continue;
  396. let is_goods = false;
  397. for (let item2 of this.package[this.package_index]){
  398. if(item.id == item2.id){
  399. is_goods = true;
  400. item2.total += item.total;
  401. break;
  402. }
  403. }
  404. if(!is_goods){
  405. this.package[this.package_index].push(JSON.parse(JSON.stringify(item)));
  406. }
  407. }
  408. this.filterGoods();
  409. this.goods_view = false;
  410. this.goods_view2 = false;
  411. },
  412. // 删除商品
  413. delGoods(package_index, goods_index) {
  414. this.package[package_index].splice(goods_index, 1);
  415. if (this.package[package_index].length == 0) {
  416. this.package.splice(package_index, 1);
  417. }
  418. this.filterGoods();
  419. },
  420. // 统计剩余商品数量
  421. statisticsGoodsNum(order_goods_id) {
  422. let num = 0;
  423. if(order_goods_id){
  424. for (let v of this.surplus_goods) {
  425. if (v.id == order_goods_id){
  426. num = v.size_num;
  427. }
  428. }
  429. return num;
  430. }
  431. for (let v of this.surplus_goods) {
  432. num += v.total;
  433. }
  434. return num;
  435. },
  436. // 统计包裹商品
  437. statisticsPackageGoodsNum(package_index){
  438. let num = 0;
  439. for (let item of this.package[package_index]){
  440. num += item.total;
  441. }
  442. return num;
  443. },
  444. // 多选
  445. handleSelectionChange(sel) {
  446. this.select_change = sel;
  447. },
  448. // 关闭商品窗口
  449. handleClose(){
  450. this.goods_view2 = false;
  451. this.package_index = 0;
  452. this.goods_view = false;
  453. this.select_change = [];
  454. },
  455. // 关闭包裹窗口
  456. closePackageView() {
  457. this.order_id = 0,
  458. this.order_goods = [];// 订单商品
  459. this.template_list = [];// 打印模板
  460. this.package = [];// 包裹
  461. this.surplus_goods = [];
  462. this.select_change = [];
  463. this.goods_view = false;
  464. this.package_view = false;
  465. this.goods_view2 = false;
  466. this.package_index = 0;
  467. },
  468. },
  469. template: `#electronicsBill`,
  470. });
  471. </script>