index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" >
  4. <el-form-item label="点位名称:" prop="name">
  5. <el-input
  6. v-model.trim="queryParams.name"
  7. placeholder="请输入点位名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="点位地址:" prop="address">
  14. <el-input
  15. v-model.trim="queryParams.address"
  16. placeholder="请输入点位地址"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item class="right">
  23. <el-button plain size="mini" @click="resetQuery">重置</el-button>
  24. <el-button type="primary" size="mini" @click="handleQuery">搜索</el-button>
  25. </el-form-item>
  26. <br>
  27. <el-button
  28. type="primary"
  29. size="mini"
  30. @click="handleAdd"
  31. >新增</el-button>
  32. </el-form>
  33. <el-table v-loading="loading" :data="adminList" style="margin-top:20px;" border>
  34. <el-table-column label="点位名称" align="center" prop="name" show-overflow-tooltip />
  35. <el-table-column label="点位地址" align="center" prop="address" show-overflow-tooltip />
  36. <el-table-column label="摄像头名称" align="center" prop="dhDeviceName" show-overflow-tooltip />
  37. <el-table-column label="摄像头通道ID" align="center" prop="vidCode" show-overflow-tooltip />
  38. <el-table-column label="点位标签" align="center" prop="qrCodeUrl" show-overflow-tooltip >
  39. <template slot-scope="scope">
  40. <el-image
  41. v-if="scope.row.qrCodeUrl"
  42. style="width: 24px; height: 24px"
  43. :preview-src-list="[scope.row.qrCodeUrl]"
  44. :src="scope.row.qrCodeUrl">
  45. </el-image>
  46.   </template>
  47. </el-table-column>
  48. <el-table-column label="创建时间" align="center" prop="createTime" show-overflow-tooltip />
  49. <el-table-column label="创建人" align="center" prop="createBy" show-overflow-tooltip />
  50. <el-table-column label="修改时间" align="center" prop="updateTime" show-overflow-tooltip />
  51. <el-table-column label="修改人" align="center" prop="updateBy" show-overflow-tooltip />
  52. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
  53. <template slot-scope="scope">
  54. <el-button
  55. size="mini"
  56. class="lans"
  57. @click="handleUpdate(scope.row)"
  58. >修改</el-button>
  59. <el-button
  60. size="mini"
  61. class="lans"
  62. @click="handleDelete(scope.row)"
  63. >删除</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <!-- 修改、新增对话框 -->
  68. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :before-close="cancel" :close-on-click-modal="false">
  69. <el-form ref="form" :model="form" :rules="rules" label-width="auto" >
  70. <el-row :gutter="10">
  71. <el-col :span="12" >
  72. <el-form-item label="点位名称" prop="name">
  73. <el-input v-model="form.name" placeholder="请填写点位名称" @input="onInput()" maxlength="15" show-word-limit width="30%"/>
  74. </el-form-item>
  75. </el-col>
  76. <el-col :span="12" >
  77. <el-form-item label="点位地址" prop="address">
  78. <el-input v-model="form.address" placeholder="请填写点位地址" @input="onInput()" maxlength="15" show-word-limit width="30%"/>
  79. </el-form-item>
  80. </el-col>
  81. <el-col :span="12" >
  82. <el-form-item label="摄像头名称" prop="vidCode">
  83. <el-select
  84. v-model="form.vidCode"
  85. placeholder="请选择摄像头名称"
  86. size="small"
  87. style="width: 160px"
  88. >
  89. <el-option
  90. v-for="dict in cocalChannelList"
  91. :key="dict.id"
  92. :label="dict.name"
  93. :value="dict.id"
  94. />
  95. </el-select>
  96. </el-form-item>
  97. </el-col>
  98. <!-- <el-col :span="12">
  99. <el-form-item label="设备类型" prop="dwtype">
  100. <el-select v-model="form.dwtype" placeholder="请选择设备类型">
  101. <el-option
  102. v-for="item in dwtypeList"
  103. :key="item.id"
  104. :label="item.name"
  105. :value="item.id"
  106. ></el-option>
  107. </el-select>
  108. </el-form-item>
  109. </el-col> -->
  110. <!-- <el-col :span="12">
  111. <el-form-item label="点位图片上传" prop="pictureRoute">
  112. <el-upload
  113. class="upload-demo"
  114. action="#"
  115. accept=".jpeg,.png,.jpg,.gif,.PNG,.JPG,.JPEG,.GIF"
  116. :limit = 1
  117. :on-change="handleChange"
  118. :file-list="fileList"
  119. >
  120. <el-button size="small" type="primary">点击上传</el-button>
  121. </el-upload>
  122. </el-form-item>
  123. </el-col> -->
  124. </el-row>
  125. </el-form>
  126. <div slot="footer" class="dialog-footer">
  127. <el-button type="primary" @click="submitForm">确 定</el-button>
  128. <el-button @click="cancel" plain>取 消</el-button>
  129. </div>
  130. </el-dialog>
  131. <!-- <pagination
  132. v-show="total>0"
  133. :total="total"
  134. :page.sync="queryParams.current"
  135. :limit.sync="queryParams.size"
  136. @pagination="getList"
  137. /> -->
  138. <el-pagination
  139. background
  140. @current-change="handleCurrentChange"
  141. :page-sizes="[10, 15, 20, 30]"
  142. @size-change="handleSizeChange"
  143. :current-page="queryParams.pageNo"
  144. :page-size="queryParams.pageSize"
  145. layout="sizes,prev, pager, next"
  146. :total="totalCount"
  147. >
  148. </el-pagination>
  149. <div class="qrcode" ref="qrCodeUrl" style="position: absolute;z-index: -1;opacity: 0;"></div>
  150. <a href="" download="" id="xz" style="position: absolute;z-index: -1;opacity: 0;"></a>
  151. </div>
  152. </template>
  153. <script>
  154. import QRCode from 'qrcodejs2'
  155. import { fileUpload } from "@/api/uploadfile.js";
  156. import { addInspectionPoint, delInspectionPoint, updateInspectionPoint, getInspectionPoint, exportInspectionPoint } from "@/api/MochaITOM/point";
  157. import { getLocalChannel, } from "@/api/device/camera";
  158. export default {
  159. name: "Floor",
  160. data() {
  161. return {
  162. exportLoading:false,
  163. // 显示搜索条件
  164. showSearch: true,
  165. // 总条数
  166. totalCount:undefined,
  167. // 参数表格数据
  168. adminList: [],
  169. // 弹出层标题
  170. title: "",
  171. // 是否显示弹出层
  172. open: false,
  173. // 查询参数
  174. queryParams: {
  175. current: 1,
  176. size: 15,
  177. name: undefined,
  178. address:undefined,
  179. pageSize:15,
  180. pageNo:1
  181. },
  182. // 表单参数
  183. form: {},
  184. // 表单校验
  185. rules: {
  186. name: [
  187. { required: true, message: "点位名称不能为空", trigger: "blur" }
  188. ],
  189. address: [
  190. { required: true, message: "点位地址不能为空", trigger: "blur" }
  191. ],
  192. vidCode: [
  193. { required: true, message: "摄像头名称不能为空", trigger: ["blur",'change'] }
  194. ],
  195. // dwtype: [
  196. // { required: true, message: "设备类型不能为空", trigger: ["blur",'change']}
  197. // ],
  198. // pictureRoute: [
  199. // { required: true, message: "文件不能为空", trigger: ["blur",'change'] }
  200. // ],
  201. },
  202. // 公司列表
  203. companyList: [],
  204. //责任人
  205. zrr:[],
  206. dwtypeList:[],
  207. num:0,
  208. fileList:[],
  209. base64:undefined,//二维码
  210. cocalChannelList:[],
  211. time:undefined
  212. };
  213. },
  214. created() {
  215. this.getList();//初始化table
  216. },
  217. methods: {
  218. //分页查询
  219. handleCurrentChange(val) {
  220. this.queryParams.pageNo = val;
  221. this.getList();
  222. },
  223. //分页查询
  224. handleSizeChange(val) {
  225. this.queryParams.pageSize = val;
  226. this.getList();
  227. },
  228. //视频通道数据
  229. // selectChanged(val){
  230. // for(let i =0;i<this.cocalChannelList.length;i++){
  231. // if(this.cocalChannelList[i].id == val){
  232. // this.form.dhDeviceName = this.cocalChannelList[i].name
  233. // }
  234. // }
  235. // },
  236. //获取视频通道
  237. getLocal(){
  238. getLocalChannel({pageNo: 1,
  239. pageSize: 1500,
  240. unitType: 1,token:"d6790e9ac3c419f6fc8d48f8c2957afd"}).then(Response =>{
  241. let data = Response.data.pageList
  242. if(data.length>0){
  243. let arr = []
  244. for(let i = 0; i<data.length;i++){
  245. arr[i] = {}
  246. arr[i].id = data[i].id
  247. arr[i].name = data[i].name
  248. }
  249. this.cocalChannelList = arr
  250. }
  251. })
  252. },
  253. creatQrCode(text) {//二维码
  254. var qrcode = new QRCode(this.$refs.qrCodeUrl, {
  255. text: "点位编号:" + text, // 需要转换为二维码的内容
  256. width: 250,
  257. height: 250,
  258. colorDark: '#000000',
  259. colorLight: '#ffffff',
  260. correctLevel: QRCode.CorrectLevel.H
  261. })
  262. setTimeout(()=>{
  263. this.base64 = window.atob(document.getElementsByClassName("qrcode")[0].getElementsByTagName("img")[0].src.split(',')[1]);
  264. this.handleChangeEWM(this.base64)
  265. },100)
  266. },
  267. handleChangeEWM(bytes){ //二维码上传
  268. var array = [];
  269. for(var i = 0; i < bytes.length; i++){
  270. array.push(bytes.charCodeAt(i));
  271. }
  272. var blob = new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
  273. var formData = new FormData();
  274. formData.append('file',blob, '.jpg');
  275. formData.append('multipart',blob, '.jpg');
  276. fileUpload(formData).then(response => {
  277. this.form.qrCodeUrl = response.data
  278. this.addData()
  279. });
  280. },
  281. handleChange(param){//点位图片上传
  282. this.num++
  283. if(this.num>1){
  284. this.num = 0
  285. return false
  286. }else{
  287. const formData = new FormData();
  288. formData.append('file', param.raw)
  289. formData.append('multipart', param.raw)
  290. fileUpload(formData).then(response => {
  291. this.msgSuccess("上传成功");
  292. this.form.pictureRoute = response.data
  293. });
  294. }
  295. },
  296. //强制el-input刷新
  297. onInput(){
  298. this.$forceUpdate();
  299. },
  300. // 取消按钮
  301. cancel() {
  302. this.open = false;
  303. setTimeout(()=>{
  304. this.reset();
  305. },1000)
  306. },
  307. /** 重置按钮操作 */
  308. resetQuery() {
  309. this.queryParams = {
  310. name:undefined,
  311. current:1,
  312. size:15,
  313. pageSize:15,
  314. pageNo:1,
  315. }
  316. //this.resetForm("queryForm");
  317. this.handleQuery();
  318. },
  319. // 表单重置
  320. reset() {
  321. this.form = {};
  322. //this.resetForm("form");
  323. },
  324. /** 搜索按钮操作 */
  325. handleQuery() {
  326. this.queryParams.current = 1;
  327. this.getList();
  328. },
  329. /** 查询参数列表 */
  330. getList() {
  331. this.loading = true;
  332. getInspectionPoint(this.queryParams).then(response => {
  333. this.adminList = response.data.pageList;
  334. this.totalCount = response.data.totalCount;
  335. this.loading = false;
  336. this.getLocal()
  337. });
  338. },
  339. /** 修改按钮操作 */
  340. handleUpdate(row) {
  341. this.reset();
  342. this.title = "修改";
  343. this.form = JSON.parse(JSON.stringify(row))
  344. this.form.buildId = Number(this.form.buildId)
  345. this.open = true;
  346. },
  347. /** 新增按钮操作 */
  348. handleAdd() {
  349. this.reset();
  350. this.open = true;
  351. this.title = "新增";
  352. this.list = []
  353. },
  354. /** 提交按钮 */
  355. submitForm(row) {
  356. this.$refs["form"].validate(valid => {
  357. if (valid) {
  358. this.form.type = 1
  359. this.loading = true
  360. if (this.form.id != undefined) {
  361. updateInspectionPoint(this.form).then(response => {
  362. this.loading = false,
  363. this.$message.success("修改成功")
  364. this.open = false;
  365. this.getList();
  366. }).catch(()=>{
  367. this.loading = false
  368. })
  369. } else {
  370. this.time = (new Date().getTime() / 1000).toFixed(0)
  371. this.form.qrContent = this.time
  372. this.creatQrCode(this.form.qrContent)
  373. }
  374. }
  375. });
  376. },
  377. /**新增 */
  378. addData(){
  379. addInspectionPoint(this.form).then(response => {
  380. this.loading = false
  381. if(response.status == "SUCCESS"){
  382. this.$message.success("新增成功")
  383. this.open = false;
  384. this.getList();
  385. }
  386. })
  387. },
  388. /** 删除按钮操作 */
  389. handleDelete(row) {
  390. const ids = row.id || this.ids;
  391. this.$confirm('是否确认删除', "警告", {
  392. confirmButtonText: "确定",
  393. cancelButtonText: "取消",
  394. type: "warning"
  395. }).then(function() {
  396. return delInspectionPoint(ids);
  397. }).then(() => {
  398. this.getList();
  399. this.$message.success("删除成功");
  400. }).catch(() => {});
  401. },
  402. /** 导出按钮操作 */
  403. handleExport() {
  404. exportInspectionPoint(this.queryParams).then(response =>{
  405. this.exportLoading = false;
  406. document.getElementById("xz").href = BASEPATH() + response.data
  407. document.getElementById("xz").download = response.data
  408. document.getElementById("xz").click()
  409. })
  410. }
  411. }
  412. };
  413. </script>