index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <!-- 信标列表 -->
  2. <template>
  3. <div class="app-container beaconList">
  4. <div class="page-container beaconListPage">
  5. <div class="page-form-title-box">
  6. <el-form :model="queryParams" class="form-box" ref="queryForm"
  7. :inline="true" style="width:100%;">
  8. <el-form-item label="关键字" prop="searchValue" label-width="60px">
  9. <el-input
  10. maxLength="30"
  11. v-model="queryParams.searchValue"
  12. placeholder="编号"
  13. clearable
  14. style="width: 200px"
  15. />
  16. </el-form-item>
  17. <el-form-item label="分类" prop="zgType" label-width="50px">
  18. <el-select v-model="queryParams.state" placeholder="请选择" clearable size="small">
  19. <el-option label="全部" value="" />
  20. <el-option label="未绑定" :value='0' />
  21. <el-option label="已绑定" :value='1' />
  22. </el-select>
  23. </el-form-item>
  24. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  25. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  26. <p class="page-add-common-style-button"
  27. style="float: right;"
  28. @click="tableButton(3)"
  29. v-hasPermi="['db:beacon:add']"
  30. >+ 新增信标</p>
  31. </el-form>
  32. </div>
  33. <div class="page-content-box">
  34. <el-table class="table-box" v-loading="loading" border :data="dataList">
  35. <el-table-column label="序号" width="50" align="center" type="index"/>
  36. <el-table-column label="信标编号" prop="beaconTag" show-overflow-tooltip/>
  37. <el-table-column label="最后使用时间" prop="bindingTime" show-overflow-tooltip>
  38. <template slot-scope="scope">
  39. <span>{{ parseTime(scope.row.bindingTime,'{y}-{m}-{d} {h}:{i}') }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column label="实验室名称" prop="subjectName" show-overflow-tooltip/>
  43. <el-table-column label="气体名称" prop="gasName" show-overflow-tooltip/>
  44. <el-table-column label="气体级别/规格" prop="size" show-overflow-tooltip/>
  45. <el-table-column label="操作" width="200" show-overflow-tooltip v-if="tableButtonType">
  46. <template slot-scope="scope">
  47. <div class="table-button-box">
  48. <p class="table-button-null"></p>
  49. <p class="table-button-p"
  50. @click="tableButton(1,scope.row)"
  51. v-hasPermi="['db:beacon:query']"
  52. >打印二维码</p>
  53. <p class="table-button-p"
  54. @click="tableButton(2,scope.row)"
  55. v-hasPermi="['db:beacon:remove']"
  56. >删除</p>
  57. <p class="table-button-null"></p>
  58. </div>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. <pagination :page-sizes="[20, 30, 40, 50]"
  63. v-show="total>0"
  64. :total="total"
  65. :page.sync="queryParams.pageNum"
  66. :limit.sync="queryParams.pageSize"
  67. @pagination="getList"
  68. />
  69. </div>
  70. </div>
  71. <el-dialog class="beaconList-dialog-box"
  72. :title="dialogTitle" :visible.sync="dialogType" v-if="dialogType"
  73. :close-on-click-modal="false" width="500px" append-to-body>
  74. <div v-if="!dialogAddType">
  75. <div v-if="dialogForm.state">
  76. <div class="text-box">
  77. <p>学院:</p>
  78. <p>{{dialogForm.collegeName}}</p>
  79. </div>
  80. <div class="text-box">
  81. <p>实验室:</p>
  82. <p>{{dialogForm.subjectName}}{{dialogForm.roomNum}}</p>
  83. </div>
  84. <!--<div class="text-box">-->
  85. <!--<p>气瓶编号:</p>-->
  86. <!--<p>{{dialogForm.roomNum}}</p>-->
  87. <!--</div>-->
  88. <div class="text-box">
  89. <p>气瓶:</p>
  90. <p>{{dialogForm.gasName}}</p>
  91. </div>
  92. </div>
  93. <div class="text-box" v-if="dialogForm.state">
  94. <p>最后一次绑定时间:</p>
  95. <p>{{ parseTime(dialogForm.bindingTime,'{y}-{m}-{d} {h}:{i}') }}</p>
  96. </div>
  97. <vue-qr style="display: block;height:100px;width:100px;margin:auto;" :text="dialogForm.beaconTag" :size="300"></vue-qr>
  98. <p class="text-p">{{dialogForm.beaconTag}}</p>
  99. <p class="text-p">信标</p>
  100. </div>
  101. <div v-if="dialogAddType">
  102. <el-form ref="dialogForm" :model="dialogForm" :rules="rules" label-width="120px">
  103. <el-form-item label="信标编号:" prop="beaconTag" style="margin-top:20px;">
  104. <el-input
  105. maxLength="20"
  106. v-model="dialogForm.beaconTag"
  107. placeholder="请输入名称"
  108. style="width: 280px"
  109. />
  110. </el-form-item>
  111. </el-form>
  112. </div>
  113. <div slot="footer" class="dialog-footer">
  114. <p class="dialog-footer-null-p"></p>
  115. <el-button @click="cancel">取 消</el-button>
  116. <el-button type="primary" @click="submit" :style="dialogAddType?'width:150px;':''">{{dialogAddType?'确认并打印二维码':'打 印'}}</el-button>
  117. <p class="dialog-footer-null-p"></p>
  118. </div>
  119. </el-dialog>
  120. </div>
  121. </template>
  122. <script>
  123. import vueQr from 'vue-qr'
  124. import { getLodop } from "@/utils/LodopFuncs";
  125. import { airbottleBeaconList,airbottleBeaconAdd,airbottleBeaconFindById,airbottleBeaconDelete } from "@/api/gasBottleManage/index";
  126. //import { getDicts } from "@/api/commonality/noPermission";
  127. //import { systemUserSelect } from "@/api/commonality/permission";
  128. //import { getInfo } from "@/api/basicsModules/index";
  129. export default {
  130. name: 'index',
  131. components: {
  132. vueQr
  133. },
  134. data () {
  135. return {
  136. tableButtonType:this.hasPermiDom(['db:beacon:remove','db:beacon:query',]),
  137. //页面遮罩
  138. loading:false,
  139. //下拉列表数据
  140. optionList:[{value:true,label:'启用'},{value:false,label:'停用'}],
  141. //查询条件
  142. queryParams:{
  143. pageNum:1,
  144. pageSize:20,
  145. searchValue:"",
  146. state:"",
  147. },
  148. //列表数据
  149. dataList:[],
  150. //数据数量
  151. total:0,
  152. //弹窗开关
  153. dialogType:false,
  154. dialogTitle:"",
  155. dialogForm:null,
  156. //打印/新增状态
  157. dialogAddType:false,
  158. //校验
  159. rules:{
  160. beaconTag:[
  161. { required: true, message: '请输入信标编号', trigger: 'blur' },
  162. { required: true, message: "请输入信标编号", validator: this.spaceJudgment, trigger: "blur" }
  163. ],
  164. },
  165. }
  166. },
  167. created () {
  168. },
  169. mounted () {
  170. this.getList();
  171. },
  172. methods: {
  173. //弹窗相关
  174. cancel(){
  175. this.$set(this,'dialogType',false);
  176. },
  177. //打印二维码
  178. submit(){
  179. let _this=this;
  180. if(!this.dialogAddType){
  181. if(this.needCLodop()){
  182. //打印
  183. if(this.dialogForm.beaconTag[0]){
  184. // let data = JSON.parse(JSON.stringify({code:this.dialogForm.beaconTag}))
  185. // let num = parseInt((20 - data.code.length)/2);
  186. // for(let i=0;i<num;i++){
  187. // data.code = ' '+data.code+' ';
  188. // }
  189. this.CreateOneFormPage(this.dialogForm.beaconTag);
  190. this.$set(this,'dialogType',false);
  191. }else{
  192. this.msgError('参数异常')
  193. }
  194. }else{
  195. //提示驱动缺失
  196. this.$set(this,'dialogType',false);
  197. this.$confirm('未检测到打印服务,请联系管理员.', "警告", {
  198. confirmButtonText: "确定",
  199. cancelButtonText: "取消",
  200. type: "warning"
  201. }).then(function() {
  202. }).then(() => {
  203. }).catch(() => {});
  204. }
  205. }else{
  206. this.$refs["dialogForm"].validate(valid => {
  207. if (valid) {
  208. let obj = JSON.parse(JSON.stringify(this.dialogForm))
  209. airbottleBeaconAdd(obj).then(response => {
  210. this.$set(this,'dialogType',false);
  211. this.msgSuccess(response.msg)
  212. this.getList();
  213. if(this.needCLodop()){
  214. //打印
  215. if(obj.beaconTag[0]){
  216. // let data = JSON.parse(JSON.stringify({code:obj.beaconTag}))
  217. // let num = parseInt((20 - data.code.length)/2);
  218. // for(let i=0;i<num;i++){
  219. // data.code = ' '+data.code+' ';
  220. // }
  221. this.CreateOneFormPage(obj.beaconTag);
  222. this.$set(this,'dialogType',false);
  223. }else{
  224. this.msgError('参数异常')
  225. }
  226. }else{
  227. //提示驱动缺失
  228. this.$set(this,'dialogType',false);
  229. this.$confirm('未检测到打印服务,请联系管理员.', "警告", {
  230. confirmButtonText: "确定",
  231. cancelButtonText: "取消",
  232. type: "warning"
  233. }).then(function() {
  234. }).then(() => {
  235. }).catch(() => {});
  236. }
  237. });
  238. }
  239. })
  240. }
  241. },
  242. //查询按钮
  243. handleQuery(){
  244. this.$set(this.queryParams,'pageNum',1);
  245. this.getList();
  246. },
  247. //重置按钮
  248. resetQuery(){
  249. this.$set(this,'dateRange',[])
  250. this.$set(this,'queryParams',{
  251. pageNum:1,
  252. pageSize:20,
  253. searchValue:"",
  254. state:"",
  255. });
  256. this.getList();
  257. },
  258. //获取数据列表
  259. getList(){
  260. this.$set(this,'loading',true);
  261. let obj = JSON.parse(JSON.stringify(this.queryParams))
  262. airbottleBeaconList(obj).then(response => {
  263. this.$set(this,'loading',false);
  264. this.$set(this,'dataList',response.data.records);
  265. this.$set(this,'total',response.data.total);
  266. });
  267. },
  268. //操作按钮
  269. tableButton(type,row){
  270. let self = this;
  271. if(type == 1){
  272. //打印二维码
  273. airbottleBeaconFindById({id:row.id}).then(response => {
  274. this.$set(this,'dialogTitle','标签信息');
  275. this.$set(this,'dialogForm',response.data);
  276. this.$set(this,'dialogAddType',false);
  277. this.$set(this,'dialogType',true);
  278. });
  279. }else if(type == 2){
  280. //删除
  281. this.$confirm('是否确认删除?', "警告", {
  282. confirmButtonText: "确定",
  283. cancelButtonText: "取消",
  284. type: "warning"
  285. }).then(function() {
  286. }).then(() => {
  287. airbottleBeaconDelete({id:row.id}).then(response => {
  288. self.msgSuccess(response.msg)
  289. self.getList();
  290. });
  291. }).catch(() => {});
  292. }else if(type == 3){
  293. //新增
  294. this.$set(this,'dialogTitle','新增');
  295. this.$set(this,'dialogForm',{beaconTag:""});
  296. this.$set(this,'dialogAddType',true);
  297. this.$set(this,'dialogType',true);
  298. }
  299. },
  300. },
  301. }
  302. </script>
  303. <style scoped lang="scss">
  304. .beaconList{
  305. display: flex;
  306. flex-direction: column;
  307. .beaconListPage{
  308. }
  309. }
  310. </style>
  311. <style lang="scss">
  312. .beaconList-dialog-box{
  313. .el-dialog__body{
  314. padding:10px 20px;
  315. .text-box{
  316. display: flex;
  317. p{
  318. font-size:16px;
  319. line-height:40px;
  320. }
  321. p:nth-child(1){
  322. margin-left:60px;
  323. }
  324. p:nth-child(2){
  325. }
  326. }
  327. .text-p{
  328. line-height:30px;
  329. font-size:16px;
  330. text-align: center;
  331. }
  332. }
  333. .dialog-footer{
  334. display: flex;
  335. .dialog-footer-null-p{
  336. flex:1;
  337. }
  338. }
  339. }
  340. </style>