table.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <scTable ref="table" :apiObj="list.apiObj" :params="searchKey" @selectionChange="selectionChange" row-key="id">
  3. <el-table-column type="selection" width="50" fixed="left"></el-table-column>
  4. <el-table-column label="序列号" prop="sn" width="220" fixed="left">
  5. <template #default="scope">
  6. <span v-if="scope.row.sn">{{ scope.row.sn }}</span>
  7. <span class="status-danger" v-else>未设置</span>
  8. </template>
  9. </el-table-column>
  10. <el-table-column label="打印机名称" prop="name" width="220">
  11. <template #default="scope">
  12. <span v-if="scope.row.name">{{ scope.row.name }}</span>
  13. <span class="status-danger" v-else>未设置</span>
  14. </template>
  15. </el-table-column>
  16. <el-table-column label="所属商家" prop="id" width="360">
  17. <template #default="scope">
  18. <div class="goods-img">
  19. <div class="name" v-if="scope.row.poi">
  20. <div class="flex-end">
  21. {{ scope.row.poi.poi_name }}
  22. </div>
  23. <span class="dec">{{ scope.row.poi.poi_address }}</span>
  24. </div>
  25. <div v-else>-</div>
  26. </div>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="设备状态" prop="device_state" width="160">
  30. <template #default="scope">
  31. <div class="status-success" v-if="scope.row.device_state==0"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  32. <div class="status-danger" v-if="scope.row.device_state==1"><sc-status-indicator type="danger"></sc-status-indicator> 开盖</div>
  33. <div class="status-info" v-if="scope.row.device_state==2"><sc-status-indicator type="info"></sc-status-indicator> 粘纸</div>
  34. <div class="status-info" v-if="scope.row.device_state==3"><sc-status-indicator type="info"></sc-status-indicator> 缺纸</div>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="在线状态" prop="status" width="160">
  38. <template #default="scope">
  39. <div class="status-success" v-if="scope.row.online=='ONLINE'"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  40. <div class="status-danger" v-if="scope.row.online=='OFFLINE'"><sc-status-indicator type="danger"></sc-status-indicator> 离线</div>
  41. <div class="status-info" v-if="scope.row.online=='UNACTIVE'"><sc-status-indicator type="info"></sc-status-indicator> 未激活</div>
  42. <div class="status-info" v-if="scope.row.online=='DISABLE'"><sc-status-indicator type="info"></sc-status-indicator> 已禁用</div>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
  46. <el-table-column label="操作" width="220" align="right" fixed="right">
  47. <template #default="scope">
  48. <el-button-group>
  49. <el-button text type="danger" size="small" @click="cancelPeint(scope.row)" v-if="scope.row.poi">解除绑定</el-button>
  50. <el-button text type="warning" size="small" @click="table_bind(scope.row)" v-else>绑定商家</el-button>
  51. <el-button text type="success" size="small" @click="table_print(scope.row)">打印测试</el-button>
  52. <el-popconfirm title="确定删除并解绑该打印机吗?" @confirm="table_del(scope.row, scope.$index)">
  53. <template #reference>
  54. <el-button text type="danger" size="small">删除</el-button>
  55. </template>
  56. </el-popconfirm>
  57. </el-button-group>
  58. </template>
  59. </el-table-column>
  60. </scTable>
  61. <formMain ref="formMain" @success="handleSuccess"></formMain>
  62. <storeData ref="storeData" :multiple="false" @success="handleStore"></storeData>
  63. </template>
  64. <script>
  65. import formMain from './form';
  66. import storeData from "@/views/manage/components/agent";
  67. export default {
  68. components: {
  69. formMain,storeData
  70. },
  71. data(){
  72. return {
  73. list: {
  74. apiObj: this.$API.print.list
  75. },
  76. dataSelect:[],
  77. dataSelectFull:[],
  78. searchKey:{},
  79. bindData:{}
  80. }
  81. },
  82. methods: {
  83. async handleStore(data){
  84. var loading = this.$loading();
  85. var resp = await this.$API.print.edit.post({"sn":this.bindData.sn,'id':this.bindData.id,'poi_id':data.poi_id});
  86. loading.close();
  87. if (resp.code == 0) {
  88. return this.$message.error(resp.msg);
  89. }
  90. this.$message.success(resp.msg);
  91. var that = this;
  92. setTimeout(function(){
  93. that.refresh()
  94. },1500);
  95. },
  96. cancelPeint(data){
  97. this.$confirm(`店铺解绑打印机后,所有核销完后订单将无法正常打印订单,确定执行解绑吗?`, '提示', {
  98. type: 'warning'
  99. }).then(async ()=>{
  100. var resp = await this.$API.print.edit.post({"sn":data.sn,'id':data.id,'poi_id':""});
  101. if (resp.code == 0) {
  102. return this.$message.error(resp.msg);
  103. }
  104. this.$message.success(resp.msg);
  105. var that = this;
  106. setTimeout(function(){
  107. that.refresh()
  108. },1500);
  109. }).catch(()=>{})
  110. },
  111. table_bind(data){
  112. this.bindData = data;
  113. this.$nextTick(() => {
  114. this.$refs.storeData.open()
  115. })
  116. },
  117. async table_print(data){
  118. var loading = this.$loading();
  119. var resp = await this.$API.print.test.post({'sn':data.sn});
  120. loading.close();
  121. if (resp.code == 0) {
  122. return this.$message.error(resp.msg);
  123. }
  124. this.$message.success(resp.msg);
  125. },
  126. refresh(){
  127. this.$refs.table.refresh()
  128. },
  129. upData(data){
  130. this.$refs.table.upData(data)
  131. },
  132. handleSuccess(){
  133. this.$refs.table.refresh()
  134. },
  135. sortChange(event){
  136. if (event.order) {
  137. var data = {
  138. "field":event.prop,
  139. "order":event.order
  140. }
  141. this.$refs.table.upData(data)
  142. } else {
  143. this.$refs.table.reload(this.searchKey)
  144. }
  145. return ;
  146. },
  147. selectionChange(event){
  148. this.dataSelect = [];
  149. var arr = [];
  150. var arrCompany = [];
  151. event.forEach(function(val,index){
  152. arr[index] = val.id;
  153. arrCompany[index] = val;
  154. });
  155. this.dataSelectFull = arrCompany;
  156. this.dataSelect = arr;
  157. this.$emit("success",this.dataSelect);
  158. this.$emit("successFull",this.dataSelectFull);
  159. },
  160. }
  161. }
  162. </script>
  163. <style>
  164. .order-name span{display: block;}
  165. .order-name span.dec{color: #999;font-size: 12px;}
  166. .goods-img{display: flex;gap: 5px;}
  167. .goods-img .name span{display: block;}
  168. .goods-img .name span.dec{color: #999;font-size: 12px;}
  169. .desc{
  170. color: #999;
  171. font-size: 12px;
  172. }
  173. .flex-btn{
  174. display: flex;
  175. flex-wrap: wrap;
  176. gap: 5px;
  177. }
  178. .flex-tags {
  179. display: flex;
  180. gap: 2px;
  181. flex-wrap: wrap;
  182. }
  183. .flex-btn .el-button.is-text{
  184. margin-left: 0;
  185. }
  186. .flex-tags-size{
  187. font-size: 12px;
  188. }
  189. .flex-tags-size span{
  190. display: block;
  191. margin-bottom: 5px;
  192. color: #999;
  193. }
  194. .flex-end{display: flex;align-items: center;justify-content: space-between;}
  195. </style>