table.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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="order_id" fixed="left">
  5. <template #default="scope">
  6. <span v-if="scope.row.name">{{ scope.row.name }}</span>
  7. <span class="status-danger" v-else>未设置</span>
  8. </template>
  9. </el-table-column>
  10. <el-table-column label="机器码" prop="open_id" width="150">
  11. <template #default="scope">
  12. <span v-if="scope.row.code">{{ scope.row.code }}</span>
  13. <span class="status-danger" v-else>未设置</span>
  14. </template>
  15. </el-table-column>
  16. <el-table-column label="打印类型" prop="out_id">
  17. <template #default="scope">
  18. <div v-if="scope.row.rule" class="flex-tag">
  19. <el-tag type="success" v-for="item in scope.row.rule.type">{{ typeData[item] }}</el-tag>
  20. </div>
  21. <span class="status-danger" v-else>未设置</span>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="支持纸张" prop="certificate_id">
  25. <template #default="scope">
  26. <div v-if="scope.row.rule" class="flex-tag">
  27. <el-tag type="danger" v-for="item in scope.row.rule.paper_size">{{ item }}</el-tag>
  28. </div>
  29. <span class="status-danger" v-else>未设置</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="支持颜色" prop="color">
  33. <template #default="scope">
  34. <div v-if="scope.row.rule" class="flex-tag">
  35. <el-tag type="warning" v-for="item in scope.row.rule.color">{{ colorData[item] }}</el-tag>
  36. </div>
  37. <span class="status-danger" v-else>未设置</span>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="支持单双面" prop="count">
  41. <template #default="scope">
  42. <div v-if="scope.row.rule" class="flex-tag">
  43. <el-tag v-for="item in scope.row.rule.duplex">{{ duplexData[item] }}</el-tag>
  44. </div>
  45. <span class="status-danger" v-else>未设置</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="取件方式" prop="order_amount">
  49. <template #default="scope">
  50. <div v-if="scope.row.rule" class="flex-tag">
  51. <el-tag v-for="item in scope.row.rule.package">{{ packageData[item] }}</el-tag>
  52. </div>
  53. <span class="status-danger" v-else>未设置</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="打印机状态" prop="pay_amount" width="150">
  57. <template #default="scope">
  58. <span v-if="scope.row.print_status">{{ scope.row.print_status }}</span>
  59. <span class="status-danger" v-else>未设置</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="开启打印" prop="status" width="180">
  63. <template #default="scope">
  64. <el-switch
  65. v-model="scope.row.status"
  66. size="large"
  67. inline-prompt
  68. :active-value="1"
  69. :inactive-value="2"
  70. active-text="启用"
  71. inactive-text="禁用"
  72. @change="table_state(scope.row)"
  73. style="--el-switch-on-color: #13ce66;"
  74. />
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="操作" width="200" align="right" fixed="right">
  78. <template #default="scope">
  79. <el-button-group>
  80. <el-button text type="warning" size="small" @click="table_edit(scope.row)">编辑</el-button>
  81. <el-button text type="success" size="small" @click="table_qrcode(scope.row)">二维码</el-button>
  82. <el-button text type="danger" size="small" @click="table_price(scope.row)" v-if="scope.row.is_price==2">额外收费</el-button>
  83. </el-button-group>
  84. </template>
  85. </el-table-column>
  86. </scTable>
  87. <formMain ref="formMain" @success="handleSuccess"></formMain>
  88. <priceMain ref="priceMain" @success="handleSuccess"></priceMain>
  89. <el-dialog :title="qrcodeTitle" v-model="visible" :width="465" destroy-on-close @closed="$emit('closed')" :close-on-click-modal="false" :close-on-press-escape="false">
  90. <div class="qrcode-img">
  91. <img :src="qrcodeImg" />
  92. </div>
  93. <template #footer>
  94. <el-button @click="visible=false">关 闭</el-button>
  95. </template>
  96. </el-dialog>
  97. </template>
  98. <script>
  99. import formMain from "./form";
  100. import priceMain from "./price";
  101. export default {
  102. components: {
  103. formMain,priceMain
  104. },
  105. data(){
  106. return {
  107. list: {
  108. apiObj: this.$API.mPrint.list
  109. },
  110. qrcodeImg:"",
  111. visible:false,
  112. qrcodeTitle:"",
  113. typeData:['','文档','照片'],
  114. colorData:['','彩色','黑白'],
  115. duplexData:['','单面','双面'],
  116. packageData:['','店内打印','远程自取','商家配送'],
  117. dataSelect:[],
  118. dataSelectFull:[],
  119. searchKey:{}
  120. }
  121. },
  122. methods: {
  123. async table_price(data){
  124. var loading = this.$loading();
  125. var resp = await this.$API.mPrint.price.get();
  126. loading.close()
  127. if (resp.code == 0) {
  128. return this.$message.error(resp.msg);
  129. }
  130. this.$nextTick(() => {
  131. this.$refs.priceMain.open("edit").setData({"id":data.id,"name":data.name,"price":resp.data})
  132. })
  133. },
  134. table_edit(data){
  135. this.$nextTick(() => {
  136. this.$refs.formMain.open("edit").setData(data)
  137. })
  138. },
  139. async table_state(data){
  140. var status = 1;
  141. if (data.status == 1) {
  142. status = 2;
  143. }
  144. var resp = await this.$API.mPrint.single.post({"id":data.id,"status":status});
  145. if (resp.code !== 1) {
  146. return this.$message.error(resp.msg);
  147. }
  148. this.$refs.table.refresh()
  149. },
  150. async table_qrcode(data){
  151. var loading = this.$loading();
  152. var resp = await this.$API.mPrint.qrcode.post({"id":data.id});
  153. loading.close()
  154. if (resp.code !== 1) {
  155. return this.$message.error(resp.msg);
  156. }
  157. this.visible = true;
  158. this.qrcodeTitle = "【"+data.name+"】打印二维码";
  159. this.qrcodeImg = resp.data.img;
  160. },
  161. refresh(){
  162. this.$refs.table.refresh()
  163. },
  164. upData(data){
  165. this.$refs.table.upData(data)
  166. },
  167. handleSuccess(){
  168. this.$refs.table.refresh()
  169. },
  170. sortChange(event){
  171. if (event.order) {
  172. var data = {
  173. "field":event.prop,
  174. "order":event.order
  175. }
  176. this.$refs.table.upData(data)
  177. } else {
  178. this.$refs.table.reload(this.searchKey)
  179. }
  180. return ;
  181. },
  182. selectionChange(event){
  183. this.dataSelect = [];
  184. var arr = [];
  185. var arrCompany = [];
  186. event.forEach(function(val,index){
  187. arr[index] = val.id;
  188. arrCompany[index] = val;
  189. });
  190. this.dataSelectFull = arrCompany;
  191. this.dataSelect = arr;
  192. this.$emit("success",this.dataSelect);
  193. this.$emit("successFull",this.dataSelectFull);
  194. },
  195. }
  196. }
  197. </script>
  198. <style>
  199. .flex-tag{display: flex;align-items: center;gap: 10px;}
  200. </style>