list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <base-page>
  3. <view class="printerlist">
  4. <view class="printerlist-box">
  5. <view class="printerlist-left">
  6. <view class="printer-title">
  7. 打印机
  8. <text class="iconfont icongengduo1"></text>
  9. </view>
  10. <view class="printer-list-wrap">
  11. <block v-if="list.length > 0">
  12. <scroll-view scroll-y="true" class="printer-list-scroll all-scroll" @scrolltolower="getPrinterList">
  13. <view
  14. class="item"
  15. @click="printerSelect(item, index)"
  16. v-for="(item, index) in list"
  17. :key="index"
  18. :class="index == selectprinterKeys ? 'itemhover' : ''"
  19. >
  20. <view class="item-right">
  21. <view class="printer-name">{{ item.printer_name }}</view>
  22. <view class="printer-money">{{ brandList[item.brand] }}</view>
  23. </view>
  24. </view>
  25. </scroll-view>
  26. </block>
  27. <view class="notYet" v-else-if="!one_judge && list.length == 0">暂无打印机</view>
  28. </view>
  29. <view class="add-printer"><button type="default" class="primary-btn" @click="addprinter">添加打印机</button></view>
  30. </view>
  31. <view class="printerlist-right" v-show="!one_judge">
  32. <view class="printer-title">打印机详情</view>
  33. <view class="printer-information">
  34. <block v-if="JSON.stringify(detail) != '{}'">
  35. <view class="title">基本信息</view>
  36. <view class="information-box">
  37. <view class="box-left">
  38. <view class="information">
  39. <view>名称:</view>
  40. <view>{{ detail.printer_name }}</view>
  41. </view>
  42. <view class="information">
  43. <view>品牌:</view>
  44. <view>{{ brandList[detail.brand] }}</view>
  45. </view>
  46. <view class="information">
  47. <view>打印机编号:</view>
  48. <view>{{ detail.printer_code }}</view>
  49. </view>
  50. <view class="information">
  51. <view>打印机秘钥:</view>
  52. <view>{{ detail.printer_key }}</view>
  53. </view>
  54. <view class="information">
  55. <view>应用id:</view>
  56. <view>{{ detail.open_id }}</view>
  57. </view>
  58. <view class="information">
  59. <view>apiKey:</view>
  60. <view>{{ detail.apikey }}</view>
  61. </view>
  62. <view class="information">
  63. <view>添加时间:</view>
  64. <view>{{ detail.create_time ? $util.timeFormat(detail.create_time) : '--' }}</view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="title">支付打印</view>
  69. <view class="information-box">
  70. <view class="box-left">
  71. <view class="information">
  72. <view>支付打印:</view>
  73. <view>{{ detail.order_pay_open ? '开启' : '关闭' }}</view>
  74. </view>
  75. <view class="information" v-if="detail.order_pay_open">
  76. <view>打印模板:</view>
  77. <view>{{ template[detail.order_pay_template_id] ? template[detail.order_pay_template_id].template_name : '--' }}</view>
  78. </view>
  79. <view class="information" v-if="detail.order_pay_open">
  80. <view>打印联数:</view>
  81. <view>{{ detail.order_pay_print_num }}</view>
  82. </view>
  83. <view class="information" v-if="detail.order_pay_open">
  84. <view>订单类型:</view>
  85. <view>
  86. <block v-for="(item, index) in detail.order_pay_order_type" :key="index">
  87. <text v-if="item" class="order-type">{{ detail['order_type_list'][item]['name'] }}</text>
  88. </block>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="title">收货打印</view>
  94. <view class="information-box">
  95. <view class="box-left">
  96. <view class="information">
  97. <view>收货打印:</view>
  98. <view>{{ detail.take_delivery_open ? '开启' : '关闭' }}</view>
  99. </view>
  100. <view class="information" v-if="detail.take_delivery_open">
  101. <view>打印模板:</view>
  102. <view>{{ template[detail.take_delivery_template_id] ? template[detail.take_delivery_template_id].template_name : '--' }}</view>
  103. </view>
  104. <view class="information" v-if="detail.take_delivery_open">
  105. <view>打印联数:</view>
  106. <view>{{ detail.take_delivery_print_num }}</view>
  107. </view>
  108. <view class="information" v-if="detail.take_delivery_open">
  109. <view>订单类型:</view>
  110. <view>
  111. <block v-for="(item, index) in detail.take_delivery_order_type" :key="index">
  112. <text v-if="item" class="order-type">{{ detail['order_type_list'][item]['name'] }}</text>
  113. </block>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="title">手动打印</view>
  119. <view class="information-box">
  120. <view class="box-left">
  121. <view class="information">
  122. <view>手动打印:</view>
  123. <view>{{ detail.manual_open ? '开启' : '关闭' }}</view>
  124. </view>
  125. <view class="information" v-if="detail.manual_open">
  126. <view>打印模板:</view>
  127. <view>{{ template[detail.template_id] ? template[detail.template_id].template_name : '--' }}</view>
  128. </view>
  129. <view class="information" v-if="detail.manual_open">
  130. <view>打印联数:</view>
  131. <view>{{ detail.print_num }}</view>
  132. </view>
  133. </view>
  134. </view>
  135. <view class="title">充值打印</view>
  136. <view class="information-box">
  137. <view class="box-left">
  138. <view class="information">
  139. <view>充值打印:</view>
  140. <view>{{ detail.recharge_open ? '开启' : '关闭' }}</view>
  141. </view>
  142. <view class="information" v-if="detail.recharge_open">
  143. <view>打印模板:</view>
  144. <view>{{ template[detail.recharge_template_id] ? template[detail.recharge_template_id].template_name : '--' }}</view>
  145. </view>
  146. <view class="information" v-if="detail.recharge_open">
  147. <view>打印联数:</view>
  148. <view>{{ detail.recharge_print_num }}</view>
  149. </view>
  150. </view>
  151. </view>
  152. <view class="title">收银交班打印</view>
  153. <view class="information-box">
  154. <view class="box-left">
  155. <view class="information">
  156. <view>收银交班打印:</view>
  157. <view>{{ detail.change_shifts_open ? '开启' : '关闭' }}</view>
  158. </view>
  159. <view class="information" v-if="detail.change_shifts_open">
  160. <view>打印模板:</view>
  161. <view>{{ template[detail.change_shifts_template_id] ? template[detail.change_shifts_template_id].template_name : '--' }}</view>
  162. </view>
  163. <view class="information" v-if="detail.change_shifts_open">
  164. <view>打印联数:</view>
  165. <view>{{ detail.change_shifts_print_num }}</view>
  166. </view>
  167. </view>
  168. </view>
  169. <view class="button-box">
  170. <view class="button" @click="deleteprinter(detail.printer_id)">删除</view>
  171. <view class="button" @click="editprinter(detail.printer_id)">修改</view>
  172. </view>
  173. </block>
  174. <block v-else><image class="cart-empty" :src="$util.img('upload/uniapp/cashier/cart_empty.png')" mode="widthFix"></image></block>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. </base-page>
  180. </template>
  181. <script>
  182. import unipopup from '@/components/uni-popup/uni-popup.vue';
  183. export default {
  184. components: { unipopup },
  185. data() {
  186. return {
  187. selectprinterKeys: 0,
  188. search_text: '',
  189. page: 1,
  190. // 每次返回数据数
  191. page_size: 8,
  192. // 第一次请求列表做详情渲染判断
  193. one_judge: true,
  194. //详情数据
  195. detail: {},
  196. brandList: {
  197. yilianyun: '易联云',
  198. '365': '365'
  199. },
  200. template: {},
  201. list: []
  202. };
  203. },
  204. onLoad() {
  205. // 初始化请求打印机列表数据
  206. this.getTemplate();
  207. },
  208. methods: {
  209. printerSelect(item, keys) {
  210. this.selectprinterKeys = keys;
  211. this.getPrinterDetail(item.printer_id);
  212. },
  213. // 搜索员工
  214. search() {
  215. this.page = 1;
  216. this.list = [];
  217. this.one_judge = true;
  218. this.getPrinterList();
  219. },
  220. addprinter() {
  221. this.$util.redirectTo('/pages/printer/add');
  222. },
  223. editprinter(printer_id) {
  224. this.$util.redirectTo('/pages/printer/add', { printer_id: printer_id });
  225. },
  226. /**
  227. * 请求的列表数据
  228. */
  229. getPrinterList() {
  230. this.$api.sendRequest({
  231. url: '/printer/storeapi/printer/lists',
  232. data: {
  233. page: this.page,
  234. page_size: this.page_size
  235. },
  236. success: res => {
  237. if (res.data.list.length == 0 && this.one_judge) {
  238. this.detail = {};
  239. this.one_judge = false;
  240. }
  241. if (res.code >= 0 && res.data.list.length != 0) {
  242. this.page += 1;
  243. if (this.list.length == 0) {
  244. this.list = res.data.list;
  245. } else {
  246. this.list = this.list.concat(res.data.list);
  247. }
  248. //初始时加载一遍详情数据
  249. if (this.one_judge) {
  250. this.getPrinterDetail(this.list[0].printer_id);
  251. }
  252. }
  253. }
  254. });
  255. },
  256. imgError(index) {
  257. this.list[index].printer_img = this.util.img('addon/meirong/o2o/img/default_printer.png');
  258. },
  259. imgDetailError() {
  260. this.detail.printer_img = this.util.img('addon/meirong/o2o/img/default_printer.png');
  261. },
  262. getTemplate() {
  263. this.$api.sendRequest({
  264. url: '/printer/storeapi/printer/template',
  265. success: res => {
  266. if (res.code == 0) {
  267. let template = {};
  268. res.data.forEach(item => {
  269. template[ item.template_id ] = item;
  270. })
  271. this.template = template;
  272. this.getPrinterList();
  273. }
  274. }
  275. });
  276. },
  277. getPrinterDetail(printer_id) {
  278. this.$api.sendRequest({
  279. url: '/printer/storeapi/printer/info',
  280. data: { printer_id },
  281. success: res => {
  282. if (res.code == 0) {
  283. this.detail = res.data;
  284. this.one_judge = false;
  285. }
  286. }
  287. });
  288. },
  289. deleteprinter(printer_id) {
  290. let that = this;
  291. uni.showModal({
  292. title: '',
  293. content: '确定要删除吗',
  294. success: function(res) {
  295. if (res.confirm) {
  296. that.$api.sendRequest({
  297. url: '/printer/storeapi/printer/deleteprinter',
  298. data: {
  299. printer_id
  300. },
  301. success: res => {
  302. if (res.code >= 0) {
  303. that.page = 1;
  304. that.list = [];
  305. that.one_judge = true;
  306. that.getPrinterList();
  307. } else {
  308. that.$util.showToast({ title: res.message });
  309. }
  310. }
  311. });
  312. } else if (res.cancel) {
  313. console.log('用户点击取消');
  314. }
  315. }
  316. });
  317. }
  318. }
  319. };
  320. </script>
  321. <style scoped lang="scss">
  322. @import './public/css/printer.scss';
  323. </style>