index.vue 14 KB

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