detail.blade.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. @extends('layouts.base')
  2. @section('content')
  3. @section('title', '添加模板')
  4. <link rel="stylesheet" type="text/css" href="{{static_url('yunshop/goods/vue-goods1.css')}}" />
  5. <link rel="stylesheet" href="{{resource_get('plugins/more-printer/assets/css/temp-detail.css?time='.time())}}">
  6. <div id="app">
  7. <div class="all">
  8. <div class="vue-head">
  9. <div class="vue-main-title">
  10. <div class="vue-main-title-left"></div>
  11. <div class="vue-main-title-content">消息模板信息</div>
  12. </div>
  13. <div style="padding: 10px;">
  14. <div style="color:#333333;margin-bottom:14px">订单商品详情默认打印,按照打印列格式打印</div>
  15. <div style="background-color: #F6F7F9;width:480px;border-radius: 6px;">
  16. <table style="width:460px;height:120px;align:center;cellspace:0;cellpading:0">
  17. <tr align="center">
  18. <td>名称</td>
  19. <td>单价</td>
  20. <td>数量</td>
  21. <td>金额</td>
  22. </tr>
  23. <tr align="center">
  24. <td>商品名称1</td>
  25. <td>¥100.00</td>
  26. <td>1</td>
  27. <td>¥100.00</td>
  28. </tr>
  29. <tr align="center">
  30. <td>商品名称2</td>
  31. <td>¥100.00</td>
  32. <td>1</td>
  33. <td>¥100.00</td>
  34. </tr>
  35. </table>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="vue-main">
  40. <el-row>
  41. <el-col :span="16">
  42. <div class="top-box">
  43. <div style="padding: 50px 50px;">
  44. <el-form label-position="right" label-width="80px" :model="form">
  45. <el-form-item label="模板名称" label-width="200px">
  46. <el-input placeholder="小票模板名称,例:订单打印小票" v-model="form.title" @focus="focus"></el-input>
  47. </el-form-item>
  48. <el-form-item label="打印头部" label-width="200px">
  49. <el-input v-model="form.print_title" @focus="focus"></el-input>
  50. <span class="help-block">打印头部信息,比如商家名称 建议不超过8个字,会进行加粗处理</span>
  51. </el-form-item>
  52. <el-form-item label="打印描述" label-width="200px">
  53. <el-input v-model="form.print_describe" @focus="focus"></el-input>
  54. <div class="tip">打印描述显示在头部和打印列中间,符号'|'分隔为一行,例如:描述1|描述2</div>
  55. </el-form-item>
  56. <el-form-item label="字体放大一倍" label-width="200px">
  57. <el-switch v-model="form.print_describe_enlarge" active-color="#29BA9C" inactive-color="#DCDFE6" active-value="on" inactive-value="off">
  58. </el-switch>
  59. <span class="help-block" style="color: #F30000;">注:放大一倍,默认关闭</span>
  60. </el-form-item>
  61. <el-form-item label="打印列格式" label-width="200px">
  62. <el-input v-model="form.print_style" @focus="focus"></el-input>
  63. <div class="tip">
  64. <span class="help-block">
  65. 例如:
  66. <span style="color: #F30000;">名称:6|单价:6|数量:5|金额:5|折后实付:10</span>
  67. 解释: 名称 占据6位,单价占据6位,数量占据5位,金额占据5位,折后实付占据10位;总共每行是32个字符,每个中文或中文标点占用2字符;请严格按照格式来!
  68. </span>
  69. <br>
  70. <span class="help-block">
  71. 打印列格式顺序与打印顺序需要保持一致,避免发生占据字符错乱
  72. </span>
  73. </div>
  74. </el-form-item>
  75. <el-form-item label="打印顺序" label-width="200px">
  76. <div class="order-pane">
  77. <draggable :list="form.print_style_order_arr">
  78. <div class="order-box" v-for="(item,index) in form.print_style_order_arr" :key="index">
  79. <span class="name">[[item]]</span>
  80. <i class="el-icon-circle-close" @click="removeOrderName(item,index)"></i>
  81. </div>
  82. </draggable>
  83. </div>
  84. <div class="order-name">
  85. <span :class="item.status ? 'name no-drop' : 'name'" v-for="(item,index) in print_order_name" :key="index" @click="sureOrderName(item,index)">[[item.name]]</span>
  86. <span class="tip">不填则默认按名称,单价,数量,金额进行打印</span>
  87. </div>
  88. </el-form-item>
  89. <!-- <el-form-item label="字体放大一倍" label-width="200px">
  90. <el-switch v-model="form.print_style_enlarge" active-color="#29BA9C" inactive-color="#DCDFE6" active-value="on" inactive-value="off">
  91. </el-switch>
  92. <span class="help-block" style="color: #F30000;">注:放大一倍,默认关闭</span>
  93. </el-form-item> -->
  94. <el-form-item label="打印列头部字体放大一倍" label-width="200px">
  95. <el-switch v-model="form.print_style_head_enlarge" active-color="#29BA9C" inactive-color="#DCDFE6" active-value="on" inactive-value="off">
  96. </el-switch>
  97. <span class="help-block" style="color: #F30000;">注:放大一倍,默认关闭</span>
  98. </el-form-item>
  99. <el-form-item label="打印内容字体放大一倍" label-width="200px">
  100. <el-switch v-model="form.print_style_content_enlarge" active-color="#29BA9C" inactive-color="#DCDFE6" active-value="on" inactive-value="off">
  101. </el-switch>
  102. <span class="help-block" style="color: #F30000;">注:放大一倍,默认关闭</span>
  103. </el-form-item>
  104. <el-form-item label="打印内容" label-width="200px" v-for="(item,index) in form.print_data" :key="index">
  105. <el-input v-model="form.print_data[index]" @focus="focus">
  106. <template slot="append">
  107. <div style="cursor:pointer" @click="deleteKey(index)">
  108. <i class="el-icon-delete" style="font-size:20px"></i>
  109. </div>
  110. </template>
  111. </el-input>
  112. <span class="help-block">输入要打印的内容</span>
  113. <el-switch v-model="form.is_enlarge[index]" active-color="#29BA9C" inactive-color="#DCDFE6" active-value="on" inactive-value="off">
  114. </el-switch>
  115. <span class="help-block" style="color: #F30000;">注:放大一倍,默认关闭</span>
  116. </el-form-item>
  117. <el-button type="success" style="margin-bottom: 22px; margin-left:100px;background-color:#29BA9C" @click="appendKey"><i class="el-icon-plus">增加一条键</i></el-button>
  118. <el-form-item label="打印二维码" label-width="200px">
  119. <el-input v-model="form.qr_code" @focus="focus"></el-input>
  120. <span class="help-block">为空则不显示</span>
  121. </el-form-item>
  122. </el-form>
  123. </div>
  124. </div>
  125. </el-col>
  126. <el-col :span="8" :push="2" style="margin-top: 35px;position:fixed;left:75%;top:300px" class="fixed-pane">
  127. <el-select v-model="value" placeholder="请选择">
  128. <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
  129. </el-option>
  130. </el-select>
  131. <div v-if="value == '1'">
  132. <div style="background-color:#F6F7F9;border-radius: 6px;color: #333333;padding:8px;margin-top:12px;width:340px">
  133. 点击变量后会自动插入选择的文本框的焦点位置,
  134. <div>在打印时系统会自动替换对应变量值</div>
  135. <div style="margin-top: 14px;color:#F30000">注意:以上模板消息变量只适用于小票打印</div>
  136. </div>
  137. </div>
  138. <div v-if="value == '2'" style="width: 340px;">
  139. <div style="color: #353535;line-height: 48px;font-size:16px;margin-left:10px;color:#353535;font-weight:500">订单变量</div>
  140. <el-tag style="border-color: #C8CEDE;margin-bottom: 12px;margin-right: 12px;color:#333333" color="#fff" @click="chose(item)" v-for="(item,index) in order_name" :key="index">[[item]]</el-tag>
  141. <div style="background-color:#F6F7F9;border-radius: 6px;color: #333333;padding:8px;margin-top:12px">
  142. 点击变量后会自动插入选择的文本框的焦点位置,
  143. <div>在打印时系统会自动替换对应变量值</div>
  144. <div style="margin-top: 14px;color:#F30000">注意:以上模板消息变量只适用于小票打印</div>
  145. </div>
  146. </div>
  147. </el-col>
  148. </el-row>
  149. </div>
  150. <div class="vue-page">
  151. <div class="vue-center">
  152. <el-button type="primary" @click="submit">提交</el-button>
  153. <el-button @click="backTo">返回列表</el-button>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. <script src="{{resource_get('resources/views/goods/assets/js/vueDraggable/sortable.js')}}"></script>
  159. <script src="{{resource_get('resources/views/goods/assets/js/vueDraggable/vuedraggable.js')}}"></script>
  160. <script language='javascript'>
  161. let id = "{{ request()-> id }}"
  162. //vue
  163. var app = new Vue({
  164. el: "#app",
  165. delimiters: ['[[', ']]'],
  166. data() {
  167. let url = '{!! $url !!}'
  168. return {
  169. form: {
  170. title: '',
  171. print_title: '',
  172. print_style: '',
  173. print_style_enlarge: 'off',
  174. print_data: [],
  175. is_enlarge: [],
  176. qr_code: '',
  177. print_describe:'',
  178. print_describe_enlarge:'',
  179. print_style_head_enlarge: '',
  180. print_style_content_enlarge: '',
  181. print_style_order_arr: [],
  182. },
  183. url:url,
  184. value: '',
  185. options: [{
  186. value: '1',
  187. label: '选择模板变量类型'
  188. }, {
  189. value: '2',
  190. label: '订单打印'
  191. }, ],
  192. order_name: ['订单编号', '订单金额', '订单时间', '订单状态', '商品条码', '商品编号', '优惠金额', '抵扣金额', '收货地址', '运费', '备注', '姓名', '电话', '订单应付金额', '提货人姓名', '提货人手机号','商品总数',
  193. '售后单号','售后状态','售后类型','收货状态','退款完成时间','退款原因'],
  194. current_input_obj: null,
  195. print_order_name:[{
  196. name:'名称',
  197. status: false
  198. },{
  199. name:'单价',
  200. status: false
  201. },{
  202. name:'数量',
  203. status: false
  204. },{
  205. name:'金额',
  206. status: false
  207. },{
  208. name:'折后实付',
  209. status: false
  210. }]
  211. }
  212. },
  213. computed: {
  214. },
  215. mounted() {
  216. if (id) {
  217. this.getTempDetail()
  218. }
  219. },
  220. methods: {
  221. //选择变量
  222. chose(item) {
  223. if (this.current_input_obj) {
  224. this.current_input_obj.target.value += `[${item}]`
  225. this.current_input_obj.target.dispatchEvent(new Event('input')) //通过触发自定义input事件实现vue中绑定的数据更新
  226. } else {
  227. return
  228. }
  229. },
  230. //聚焦
  231. focus(event) {
  232. this.current_input_obj = event
  233. },
  234. //返回列表
  235. backTo() {
  236. let url = this.url
  237. window.location.href=url
  238. },
  239. //删除一条键
  240. deleteKey(index) {
  241. this.form.print_data.splice(index, 1)
  242. this.form.is_enlarge.splice(index, 1)
  243. },
  244. //增加一条键
  245. appendKey() {
  246. this.form.print_data.push("")
  247. this.form.is_enlarge.push('off')
  248. },
  249. //提交表单
  250. submit() {
  251. let url=window.location.href
  252. let json = {
  253. title: this.form.title,
  254. print_data: this.form.print_data,
  255. print_style: this.form.print_style,
  256. qr_code: this.form.qr_code,
  257. print_title: this.form.print_title,
  258. print_describe: this.form.print_describe,
  259. print_describe_enlarge: this.form.print_describe_enlarge,
  260. print_style_head_enlarge: this.form.print_style_head_enlarge,
  261. print_style_content_enlarge: this.form.print_style_content_enlarge,
  262. print_style_order_arr: this.form.print_style_order_arr
  263. }
  264. if(this.form.print_style_enlarge =='on'){
  265. json.print_style_enlarge = 'on'
  266. }else{
  267. }
  268. json.is_enlarge = []
  269. this.form.is_enlarge.forEach((item,index) => {
  270. if(item == 'on'){
  271. json.is_enlarge[index] = item
  272. }
  273. });
  274. if(json.is_enlarge.length == 0){
  275. delete json.is_enlarge
  276. }
  277. if (id) {
  278. this.$http.post(url, {
  279. temp: {
  280. id,
  281. ...json
  282. }
  283. }).then((res) => {
  284. if (res.data.result) {
  285. this.$message.success(res.data.msg)
  286. window.location.href=this.url
  287. } else {
  288. this.$message.error(res.data.msg);
  289. }
  290. })
  291. } else {
  292. if (this.form.print_data < 1) {
  293. this.$message.error('请添加一个键')
  294. } else {
  295. this.$http.post(url, {
  296. temp: {
  297. ...json
  298. }
  299. }).then((res) => {
  300. if (res.data.result) {
  301. this.$message.success(res.data.msg)
  302. window.location.href=this.url
  303. } else {
  304. this.$message.error(res.data.msg);
  305. }
  306. })
  307. }
  308. }
  309. },
  310. //获取模板详情
  311. getTempDetail() {
  312. let data_url=window.location.href
  313. this.$http.get(data_url, {
  314. id
  315. }).then((res) => {
  316. if (res.data.result) {
  317. let data = res.data.data.data
  318. this.form.title = data.title
  319. this.form.print_title = data.print_title
  320. this.form.print_style = data.print_style
  321. this.form.print_style_enlarge = data.print_style_enlarge
  322. this.form.print_data = data.print_data?data.print_data:[]
  323. this.form.is_enlarge = data.is_enlarge?data.is_enlarge:[]
  324. this.form.qr_code = data.qr_code;
  325. this.form.print_describe = data.print_describe;
  326. this.form.print_describe_enlarge = data.print_describe_enlarge;
  327. this.form.print_style_head_enlarge = data.print_style_head_enlarge;
  328. this.form.print_style_content_enlarge = data.print_style_content_enlarge;
  329. this.form.print_style_order_arr = Array.isArray(data.print_style_order_arr) ? data.print_style_order_arr : [];
  330. for(let item of this.print_order_name) {
  331. for(let citem of this.form.print_style_order_arr) {
  332. if(citem == item.name) {
  333. item.status = true;
  334. }
  335. }
  336. }
  337. } else {
  338. this.$message.error(res.data.msg);
  339. }
  340. })
  341. },
  342. //选中排序名称
  343. sureOrderName(row,index) {
  344. if(row.status) return
  345. this.print_order_name[index].status = true;
  346. this.form.print_style_order_arr.push(row.name);
  347. },
  348. //移出选中排序名称
  349. removeOrderName(name,index) {
  350. this.form.print_style_order_arr.splice(index,1);
  351. let index_of = this.print_order_name.findIndex(item => item.name == name);
  352. this.print_order_name[index_of].status = false;
  353. }
  354. },
  355. })
  356. </script>
  357. @endsection