editPrinter.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="page-block">
  5. <view class="page-title-block">
  6. <view class="title">基本信息</view>
  7. </view>
  8. <view class="content">
  9. <view class="cell flex flex-y-center arr-r" v-if="type==1">
  10. <view class="title-block required">
  11. <text>所属门店</text>
  12. </view>
  13. <view class="desc">
  14. <picker mode="selector" :range="tableTypeList" range-key="title"
  15. @change="onTableTypeChange">
  16. <view>
  17. {{tableTypeActive}}
  18. </view>
  19. </picker>
  20. </view>
  21. </view>
  22. <view class="cell flex flex-y-center">
  23. <view class="title-block required">
  24. <text>设备名称</text>
  25. </view>
  26. <view class="desc">
  27. <input type="text" :value="info.name" name="name" class="input-box" placeholder="请输入"
  28. placeholder-class="desc-placeholder">
  29. </view>
  30. </view>
  31. <view class="cell flex flex-y-center arr-r">
  32. <view class="title-block required">
  33. <text>设备位置</text>
  34. </view>
  35. <view class="desc">
  36. <picker mode="selector" :range="printerAddrList" @change="onPrinterAddrChange">
  37. <view :class="[printerAddr?'':'desc-placeholder','input-box']">{{printerAddr || '请选择'}}
  38. </view>
  39. </picker>
  40. </view>
  41. </view>
  42. <view class="cell flex flex-y-center arr-r">
  43. <view class="title-block required">
  44. <text>设备状态</text>
  45. </view>
  46. <view class="desc" @click="onPrinterStatusChange">
  47. <view class="input-box">{{printerStatus}}</view>
  48. </view>
  49. </view>
  50. <view class="cell flex flex-y-center arr-r">
  51. <view class="title-block required">
  52. <text>打印标签</text>
  53. </view>
  54. <view class="desc">
  55. <picker mode="selector" :range="listlabel" @change="onPrinterlabel" :range-key="'tag_name'">
  56. <view :class="[printerTypelabel?'':'desc-placeholder','input-box']">
  57. {{printerTypelabel || '请选择'}}
  58. </view>
  59. </picker>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- -->
  65. <view class="page-block">
  66. <view class="page-title-block">
  67. <view class="title">设备信息</view>
  68. </view>
  69. <view class="content">
  70. <view class="cell flex flex-y-center arr-r">
  71. <view class="title-block ">
  72. <text>设备类型</text>
  73. </view>
  74. <view class="desc">
  75. <picker mode="selector" :range="printerTypeList" @change="onPrinterTypeChange"
  76. :range-key="'name'">
  77. <view :class="[printerType?'':'desc-placeholder','input-box']">
  78. {{printerType|| '请选择'}}
  79. </view>
  80. </picker>
  81. </view>
  82. </view>
  83. <block v-if="printerTypeid==1">
  84. <view class="cell flex flex-y-center">
  85. <view class="title-block required">
  86. <text>设备编码</text>
  87. </view>
  88. <view class="desc">
  89. <input type="text" :value="info.dyj_id" name="dyj_id" class="input-box"
  90. placeholder="请输入打印机设备编码" placeholder-class="desc-placeholder">
  91. </view>
  92. </view>
  93. <view class="cell flex flex-y-center">
  94. <view class="title-block required">
  95. <text>API秘钥</text>
  96. </view>
  97. <view class="desc">
  98. <input type="text" :value="info.dyj_key" name="dyj_key" class="input-box"
  99. placeholder="请输入打印机API秘钥" placeholder-class="desc-placeholder">
  100. </view>
  101. </view>
  102. </block>
  103. <block v-if="printerTypeid==2">
  104. <view class="cell flex flex-y-center">
  105. <view class="title-block required">
  106. <text>打印机终端号</text>
  107. </view>
  108. <view class="desc">
  109. <input type="text" :value="info.dyj_id" name="dyj_id" class="input-box"
  110. placeholder="请输入打印机终端号" placeholder-class="desc-placeholder">
  111. </view>
  112. </view>
  113. <view class="cell flex flex-y-center">
  114. <view class="title-block required">
  115. <text>打印机终端密钥</text>
  116. </view>
  117. <view class="desc">
  118. <input type="text" :value="info.token" name="token" class="input-box"
  119. placeholder="请输入打印机终端密钥" placeholder-class="desc-placeholder">
  120. </view>
  121. </view>
  122. <view class="cell flex flex-y-center">
  123. <view class="title-block required">
  124. <text>用户id(管理中心系统集成里获取)</text>
  125. </view>
  126. <view class="desc">
  127. <input type="text" :value="info.yy_id" name="yy_id" class="input-box"
  128. placeholder="请输入用户id" placeholder-class="desc-placeholder">
  129. </view>
  130. </view>
  131. <view class="cell flex flex-y-center">
  132. <view class="title-block required">
  133. <text>apikey(管理中心系统集成里获取</text>
  134. </view>
  135. <view class="desc">
  136. <input type="text" :value="info.api" name="api" class="input-box"
  137. placeholder="请输入apikey" placeholder-class="desc-placeholder">
  138. </view>
  139. </view>
  140. </block>
  141. <block v-if="printerTypeid==3||printerTypeid==7">
  142. <view class="cell flex flex-y-center">
  143. <view class="title-block required">
  144. <text>飞鹅账号</text>
  145. </view>
  146. <view class="desc">
  147. <input type="text" :value="info.fezh" name="fezh" class="input-box"
  148. placeholder="请输入飞鹅账号" placeholder-class="desc-placeholder">
  149. </view>
  150. </view>
  151. <view class="cell flex flex-y-center">
  152. <view class="title-block required">
  153. <text>飞鹅UKEY</text>
  154. </view>
  155. <view class="desc">
  156. <input type="text" :value="info.fe_ukey" name="fe_ukey" class="input-box"
  157. placeholder="请输入UKEY" placeholder-class="desc-placeholder">
  158. </view>
  159. </view>
  160. <view class="cell flex flex-y-center">
  161. <view class="title-block required">
  162. <text>打印机编号</text>
  163. </view>
  164. <view class="desc">
  165. <input type="text" :value="info.fe_dycode" name="fe_dycode" class="input-box"
  166. placeholder="请输入打印机编号" placeholder-class="desc-placeholder">
  167. </view>
  168. </view>
  169. </block>
  170. <block v-if="printerTypeid==4">
  171. <view class="cell flex flex-y-center">
  172. <view class="title-block required">
  173. <text>打印机设备编码</text>
  174. </view>
  175. <view class="desc">
  176. <input type="text" :value="info.xx_sn" name="xx_sn" class="input-box"
  177. placeholder="请输入打印机设备编码" placeholder-class="desc-placeholder">
  178. </view>
  179. </view>
  180. </block>
  181. <block v-if="printerTypeid==5">
  182. <view class="cell flex flex-y-center">
  183. <view class="title-block required">
  184. <text>佳搏商户编号</text>
  185. </view>
  186. <view class="desc">
  187. <input type="text" :value="info.jia_bercode" name="jia_bercode" class="input-box"
  188. placeholder="请输入打印机商户编号" placeholder-class="desc-placeholder">
  189. </view>
  190. </view>
  191. <view class="cell flex flex-y-center">
  192. <view class="title-block required">
  193. <text>佳搏秘钥</text>
  194. </view>
  195. <view class="desc">
  196. <input type="text" :value="info.jia_apikey" name="jia_apikey" class="input-box"
  197. placeholder="请输入秘钥" placeholder-class="desc-placeholder">
  198. </view>
  199. </view>
  200. <view class="cell flex flex-y-center">
  201. <view class="title-block required">
  202. <text>佳搏设备号</text>
  203. </view>
  204. <view class="desc">
  205. <input type="text" :value="info.jia_deviceid" name="jia_deviceid" class="input-box"
  206. placeholder="请输入打印机设备号" placeholder-class="desc-placeholder">
  207. </view>
  208. </view>
  209. </block>
  210. <block v-if="printerTypeid==6">
  211. <view class="cell flex flex-y-center">
  212. <view class="title-block required">
  213. <text>芯烨云后台注册账号</text>
  214. </view>
  215. <view class="desc">
  216. <input type="text" :value="info.xyy_user" name="xyy_user" class="input-box"
  217. placeholder="请输入芯烨云后台注册账号" placeholder-class="desc-placeholder">
  218. </view>
  219. </view>
  220. <view class="cell flex flex-y-center">
  221. <view class="title-block required">
  222. <text>芯烨云UserKey</text>
  223. </view>
  224. <view class="desc">
  225. <input type="text" :value="info.xyy_user_key" name="xyy_user_key" class="input-box"
  226. placeholder="请输入芯烨云UserKey" placeholder-class="desc-placeholder">
  227. </view>
  228. </view>
  229. <view class="cell flex flex-y-center">
  230. <view class="title-block required">
  231. <text>打印机编号</text>
  232. </view>
  233. <view class="desc">
  234. <input type="text" :value="info.xyy_no" name="xyy_no" class="input-box"
  235. placeholder="请输入打印机编号" placeholder-class="desc-placeholder">
  236. </view>
  237. </view>
  238. </block>
  239. <block v-if="printerTypeid==8">
  240. <view class="cell flex flex-y-center">
  241. <view class="title-block required">
  242. <text>商米AppID</text>
  243. </view>
  244. <view class="desc">
  245. <input type="text" :value="info.shangmi_appid" name="shangmi_appid" class="input-box"
  246. placeholder="请输入商米AppID" placeholder-class="desc-placeholder">
  247. </view>
  248. </view>
  249. <view class="cell flex flex-y-center">
  250. <view class="title-block required">
  251. <text>商米AppKey</text>
  252. </view>
  253. <view class="desc">
  254. <input type="text" :value="info.shangmi_appkey" name="shangmi_appkey" class="input-box"
  255. placeholder="请输入商米AppKey" placeholder-class="desc-placeholder">
  256. </view>
  257. </view>
  258. <view class="cell flex flex-y-center">
  259. <view class="title-block required">
  260. <text>商米SN</text>
  261. </view>
  262. <view class="desc">
  263. <input type="text" :value="info.shangmi_sn" name="shangmi_sn" class="input-box"
  264. placeholder="请输入商米SN" placeholder-class="desc-placeholder">
  265. </view>
  266. </view>
  267. </block>
  268. </view>
  269. </view>
  270. <!-- -->
  271. <view class="page-block">
  272. <view class="page-title-block">
  273. <view class="title">打印信息</view>
  274. </view>
  275. <view class="content">
  276. <view class="cell flex flex-y-center">
  277. <view class="title-block required">
  278. <text>打印次数</text>
  279. </view>
  280. <view class="desc">
  281. <input type="text" :value="info.num" name="num" class="input-box" placeholder="请输入打印次数"
  282. placeholder-class="desc-placeholder">
  283. </view>
  284. </view>
  285. <view class="tips">
  286. 易联云打印机打印次数在易联云后台控制
  287. 喜讯打印机最大值为4
  288. </view>
  289. </view>
  290. </view>
  291. <!-- -->
  292. <view class="footer-bar" style="position: relative;">
  293. <view class="content flex flex-center" style="background: none;">
  294. <button hover-class="none" class="btn" form-type="submit">
  295. 立即添加
  296. </button>
  297. </view>
  298. </view>
  299. </form>
  300. </view>
  301. </template>
  302. <script>
  303. export default {
  304. data() {
  305. return {
  306. info: {},
  307. printerAddrList: ['前台', '厨房', '排队取号','标签打印(仅限飞鹅)'],
  308. printerAddr: '',
  309. printerStatus: '开启',
  310. printerTypeList: [{
  311. name: '365',
  312. id: 1
  313. }, {
  314. name: '易联云(型号:k4)',
  315. id: 2
  316. }, {
  317. name: '飞鹅(型号:FP-58W)',
  318. id: 3
  319. }, {
  320. name: '喜讯(型号:XP58IIQR)',
  321. id: 4
  322. },
  323. {
  324. name: '佳搏(SH584)',
  325. id: 5
  326. },
  327. {
  328. name: '芯烨云(XP-T58H)',
  329. id: 6
  330. },
  331. {
  332. name: '飞鹅(型号:FP-N20W)(仅限标签打印)',
  333. id: 7
  334. },
  335. {
  336. name: '商米(型号:NT211)',
  337. id: 8
  338. },
  339. ],
  340. printerType: '365',
  341. printerTypeid: 1,
  342. location: 1,
  343. state: 1,
  344. listlabel: [],
  345. printerTypelabel: "",
  346. tag_id: "",
  347. type: 2,
  348. tableTypeList: [],
  349. tableTypeActive: "请选择",
  350. }
  351. },
  352. onLoad(e) {
  353. this.type = e.type || 2;
  354. if (e.type == 1) {
  355. this.shop_store_index()
  356. } else {
  357. this.store_id = uni.getStorageSync("store_id")
  358. this.getData()
  359. }
  360. if (e.id) {
  361. this.printinfo(e.id)
  362. }
  363. },
  364. methods: {
  365. shop_store_index() {
  366. this.request({
  367. url: 'Smdcshop/shop_store_index',
  368. data: {
  369. admin_id: uni.getStorageSync("admin_id"),
  370. }
  371. }).then(res => {
  372. if (res.code == 200) {
  373. this.tableTypeList = res.data;
  374. }
  375. })
  376. },
  377. onTableTypeChange(e) {
  378. this.tableTypeActive = this.tableTypeList[e.detail.value].title;
  379. this.store_id = this.tableTypeList[e.detail.value].id;
  380. this.printerTypelabel = '';
  381. this.tag_id = '';
  382. this.$nextTick(()=>{
  383. this.getData();
  384. })
  385. },
  386. printinfo(id) {
  387. this.request({
  388. url: 'Smdcshop/print_update_info',
  389. data: {
  390. id,
  391. }
  392. }).then(res => {
  393. if (res.code == "200") {
  394. this.info = res.data;
  395. // 打印位置
  396. this.location = res.data.location;
  397. this.printerAddr = this.printerAddrList[Number(res.data.location) - 1]
  398. // 设备状态
  399. this.state = res.data.state;
  400. this.printerStatus = this.state == 1 ? '开启' : '关闭';
  401. // 标签
  402. for (let i of this.listlabel) {
  403. if (i.id == res.data.tag_id) {
  404. this.printerTypelabel = i.tag_name
  405. }
  406. }
  407. this.tag_id = res.data.tag_id;
  408. // 设备类型
  409. for (let i of this.printerTypeList) {
  410. if (i.id == res.data.type) {
  411. this.printerType = i.name
  412. }
  413. }
  414. this.printerTypeid = res.data.type;
  415. }
  416. })
  417. },
  418. getData(page) {
  419. this.request({
  420. url: 'Smdcshop/print_tag',
  421. data: {
  422. store_id: this.store_id
  423. }
  424. }).then(res => {
  425. if (res.code == "200") {
  426. this.listlabel = res.data
  427. }
  428. })
  429. },
  430. onPrinterlabel(e) {
  431. this.printerTypelabel = this.listlabel[e.detail.value].tag_name;
  432. this.tag_id = this.listlabel[e.detail.value].id;
  433. },
  434. onPrinterAddrChange(e) {
  435. console.log(e)
  436. this.printerAddr = this.printerAddrList[e.detail.value]
  437. this.location = Number(e.detail.value) + 1; //打印机位置:1前台,2后厨 3标签打印机
  438. },
  439. onPrinterStatusChange() {
  440. let statusArr = ['开启', '关闭']
  441. uni.showActionSheet({
  442. itemList: statusArr,
  443. success: (r) => {
  444. console.log(r.tapIndex)
  445. this.state = Number(r.tapIndex) + 1
  446. this.printerStatus = statusArr[r.tapIndex]
  447. }
  448. })
  449. },
  450. onPrinterTypeChange(e) {
  451. this.printerType = this.printerTypeList[e.detail.value].name;
  452. this.printerTypeid = this.printerTypeList[e.detail.value].id;
  453. },
  454. onSubmit(e) {
  455. let params = {
  456. state: this.state,
  457. location: this.location,
  458. tag_id: this.tag_id,
  459. store_id: this.store_id,
  460. type: this.printerTypeid,
  461. dyj_id:'',
  462. dyj_key:'',
  463. },
  464. url;
  465. var data = Object.assign(params, e.detail.value);
  466. console.log(data, "data")
  467. if (this.info.id) {
  468. params.id = this.info.id
  469. url = "Smdcshop/print_update"
  470. } else {
  471. url = 'Smdcshop/print_add'
  472. }
  473. if (data.name == "") {
  474. uni.showToast({
  475. title: "请输入名称",
  476. icon: 'none'
  477. })
  478. return false
  479. }
  480. this.request({
  481. url,
  482. data: data
  483. }).then(res => {
  484. if (res.code == 200) {
  485. uni.showToast({
  486. title: res.message,
  487. icon: 'none'
  488. })
  489. setTimeout(() => {
  490. uni.navigateBack()
  491. }, 2000)
  492. }
  493. }).catch((res) => {
  494. uni.showToast({
  495. title: res.message,
  496. icon: 'none'
  497. })
  498. });
  499. },
  500. }
  501. }
  502. </script>
  503. <style>
  504. @import url("../static/css/common.css");
  505. page {
  506. background-color: #F4F5F7;
  507. }
  508. .tips{
  509. font-size: 26rpx;
  510. color: red;
  511. padding: 20rpx 0;
  512. }
  513. </style>