index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="地图名称" prop="mapId">
  5. <el-select v-model="queryParams.mapId" placeholder="地图名称">
  6. <el-option v-for="item in this.MapOptions" :key="item.id" :label="item.name" :value="item.id">
  7. </el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item>
  11. <el-button v-no-more-click type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索
  12. </el-button>
  13. <el-button v-no-more-click icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  14. </el-form-item>
  15. </el-form>
  16. <el-row :gutter="10" class="mb8">
  17. <el-col :span="1.5">
  18. <el-button v-no-more-click
  19. type="primary"
  20. plain
  21. icon="el-icon-plus"
  22. size="mini"
  23. @click="handleAdd"
  24. v-hasPermi="['iscs:map-point:add']"
  25. >新增
  26. </el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button v-no-more-click
  30. type="danger"
  31. plain
  32. icon="el-icon-delete"
  33. size="mini"
  34. :disabled="multiple"
  35. @click="handleDelete"
  36. v-hasPermi="['iscs:map-point:remove']"
  37. >删除
  38. </el-button>
  39. </el-col>
  40. <!-- <el-button v-no-more-click-->
  41. <!-- type="info"-->
  42. <!-- plain-->
  43. <!-- icon="el-icon-upload2"-->
  44. <!-- size="mini"-->
  45. <!-- @click="handleImport"-->
  46. <!-- >导入</el-button>-->
  47. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  48. </el-row>
  49. <el-table v-loading="loading" :data="List" @selection-change="handleSelectionChange">
  50. <el-table-column type="selection" width="55" align="center"/>
  51. <el-table-column label="地图名称" align="center" width="210px" prop="mapName">
  52. <template slot-scope="scope">
  53. <span>{{ scope.row.mapName }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="地图类型" align="center" prop="mapType" :show-overflow-tooltip="true">
  57. <template slot-scope="scope">
  58. <dict-tag
  59. :options="dict.type.map_type"
  60. :value="scope.row.mapType"
  61. />
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="实体名称" align="center" width="210px" prop="entityName">
  65. <template slot-scope="scope">
  66. <span>{{ scope.row.entityName }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="横坐标" align="center" prop="x" width="180">
  70. </el-table-column>
  71. <el-table-column label="纵坐标" align="center" prop="y" width="180">
  72. </el-table-column>
  73. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  74. <template slot-scope="scope">
  75. <span>{{ scope.row.createTime }}</span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  79. <template slot-scope="scope">
  80. <el-button v-no-more-click
  81. size="mini"
  82. type="text"
  83. icon="el-icon-edit"
  84. @click="handleUpdate(scope.row)"
  85. v-hasPermi="['iscs:map-point:edit']"
  86. >修改
  87. </el-button>
  88. <el-button v-no-more-click
  89. size="mini"
  90. type="text"
  91. icon="el-icon-delete"
  92. @click="handleDelete(scope.row)"
  93. v-hasPermi="['iscs:map-point:remove']"
  94. >删除
  95. </el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. <pagination
  100. v-show="total>0"
  101. :total="total"
  102. :page.sync="queryParams.current"
  103. :limit.sync="queryParams.size"
  104. @pagination="getList"
  105. />
  106. <!-- 添加或修改参数配置对话框 -->
  107. <el-dialog :title="title" :visible.sync="open" width="400px" append-to-body>
  108. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  109. <el-form-item label="地图名称" prop="mapId">
  110. <el-select style="width: 280px" v-model="form.mapId" placeholder="地图名称">
  111. <el-option v-for="item in this.MapOptions" :key="item.id" :label="item.name" :value="item.id">
  112. </el-option>
  113. </el-select>
  114. </el-form-item>
  115. <el-form-item label="地图类型" prop="mapType">
  116. <el-select style="width: 280px" v-model="form.mapType" placeholder="地图类型">
  117. <el-option
  118. v-for="dict in dict.type.map_type"
  119. :key="dict.value"
  120. :label="dict.label"
  121. :value="dict.value"
  122. />
  123. </el-select>
  124. </el-form-item>
  125. <el-form-item v-if="form.mapType=='1'" label="实体" prop="entityId">
  126. <treeselect
  127. style="width: 280px"
  128. v-model="form.entityId"
  129. :options="deptOptions"
  130. :normalizer="Marsnormalizer"
  131. placeholder="选择实体"
  132. @change="handleWorkstationChange"
  133. />
  134. </el-form-item>
  135. <el-form-item v-if="form.mapType=='2'" label="实体" prop="entityId">
  136. <el-select style="width: 280px" v-model="form.entityId" placeholder="实体">
  137. <el-option v-for="item in this.spmOptions" :key="item.pointId" :label="item.pointName" :value="item.pointId">
  138. </el-option>
  139. </el-select>
  140. </el-form-item>
  141. <el-form-item label="横坐标" prop="x">
  142. <el-input v-model="form.x" placeholder="请输入横坐标"/>
  143. </el-form-item>
  144. <el-form-item label="纵坐标" prop="y">
  145. <el-input v-model="form.y" placeholder="请输入纵坐标"/>
  146. </el-form-item>
  147. </el-form>
  148. <div slot="footer" class="dialog-footer">
  149. <el-button v-no-more-click type="primary" @click="submitForm">确 定</el-button>
  150. <el-button v-no-more-click @click="cancel">取 消</el-button>
  151. </div>
  152. </el-dialog>
  153. <!-- 测试-->
  154. <el-dialog
  155. :title="upload.title"
  156. :visible.sync="upload.open"
  157. width="400px"
  158. append-to-body
  159. >
  160. <el-upload
  161. ref="upload"
  162. :limit="1"
  163. accept=".mp4, .pdf, .doc, .docx, .xls, .xlsx"
  164. :headers="upload.headers"
  165. :action="upload.url"
  166. :disabled="upload.isUploading"
  167. :on-progress="handleFileUploadProgress"
  168. :on-success="handleFileSuccess"
  169. :auto-upload="false"
  170. drag
  171. >
  172. <i class="el-icon-upload"></i>
  173. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  174. <div class="el-upload__tip text-center" slot="tip">
  175. <span>mp4、pdf, .doc, .docx, .xls, .xlsx格式文件。</span>
  176. </div>
  177. </el-upload>
  178. <div slot="footer" class="dialog-footer">
  179. <el-button v-no-more-click type="primary" @click="submitFileForm"
  180. >确 定</el-button
  181. >
  182. <el-button v-no-more-click @click="upload.open = false"
  183. >取 消</el-button
  184. >
  185. </div>
  186. </el-dialog>
  187. </div>
  188. </template>
  189. <script>
  190. import {
  191. deleteIsMapPointByIds,
  192. getIsMapPointPage,
  193. insertIsMapPoint,
  194. selectIsMapPointById,
  195. updateIsMapPoint
  196. } from '@/api/system/mappoint'
  197. import { getIsMapPage } from '@/api/system/mapconfig'
  198. import Treeselect from '@riophae/vue-treeselect'
  199. import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  200. import { listMarsDept } from '@/api/system/marsdept'
  201. import { getIsIsolationPointPage } from '@/api/mes/spm/segregationPoint'
  202. import { getToken } from '@/utils/auth'
  203. export default {
  204. name: 'autoCodeRule',
  205. components: { Treeselect },
  206. dicts: ['sys_yes_no', 'map_type'],
  207. data() {
  208. return {
  209. // 遮罩层
  210. loading: true,
  211. // 选中数组
  212. ids: [],
  213. // 非单个禁用
  214. single: true,
  215. // 非多个禁用
  216. multiple: true,
  217. // 显示搜索条件
  218. showSearch: true,
  219. // 总条数
  220. total: 0,
  221. // 字典表格数据
  222. List: [],
  223. // 弹出层标题
  224. title: '',
  225. // 是否显示弹出层
  226. open: false,
  227. // 查询参数
  228. queryParams: {
  229. current: 1,
  230. size: 10
  231. },
  232. // 表单参数
  233. form: {},
  234. // 地图名称 下拉
  235. MapOptions: null,
  236. // 岗位下拉
  237. deptOptions: null,
  238. // 隔离点下拉
  239. spmOptions: null,
  240. // 用户导入参数
  241. upload: {
  242. // 是否显示弹出层(用户导入)
  243. open: false,
  244. // 弹出层标题(用户导入)
  245. title: "",
  246. // 是否禁用上传
  247. isUploading: false,
  248. // 是否更新已经存在的用户数据
  249. updateSupport: 0,
  250. // 设置上传的请求头部
  251. headers: { Authorization: "Bearer " + getToken() },
  252. // 上传的地址
  253. url: process.env.VUE_APP_BASE_API + "/loginByFingerprintDat"
  254. },
  255. // 表单校验
  256. rules: {
  257. mapId: [
  258. { required: true, message: '地图名称', trigger: 'blur' }
  259. ],
  260. mapType: [
  261. { required: true, message: '地图类型', trigger: 'blur' }
  262. ]
  263. }
  264. }
  265. },
  266. created() {
  267. this.getList()
  268. this.getOtherList()
  269. },
  270. methods: {
  271. /** 导入按钮操作 */
  272. handleImport() {
  273. this.upload.title = "导入";
  274. this.upload.open = true;
  275. },
  276. // 文件上传中处理
  277. handleFileUploadProgress(event, file, fileList) {
  278. this.upload.isUploading = true;
  279. },
  280. // 文件上传成功处理
  281. handleFileSuccess(response, file, fileList) {
  282. this.upload.open = false;
  283. this.upload.isUploading = false;
  284. this.$refs.upload.clearFiles();
  285. this.$alert(
  286. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  287. response.msg +
  288. "</div>",
  289. "导入结果",
  290. { dangerouslyUseHTMLString: true }
  291. );
  292. this.getList();
  293. },
  294. // 提交上传文件
  295. submitFileForm() {
  296. this.$refs.upload.submit();
  297. },
  298. /** 查询字典类型列表 */
  299. getList() {
  300. this.loading = true
  301. getIsMapPointPage(this.queryParams).then(response => {
  302. this.List = response.data.records
  303. this.total = response.data.total
  304. this.loading = false
  305. }
  306. )
  307. },
  308. getOtherList() {
  309. const data = {
  310. current: 1,
  311. size: -1
  312. }
  313. getIsMapPage(data).then(response => {
  314. this.MapOptions = response.data.records
  315. })
  316. listMarsDept(data).then(response => {
  317. //
  318. console.log(response,'岗位')
  319. this.deptOptions = this.handleTree(response.data.records,"workstationId","parentId")
  320. })
  321. getIsIsolationPointPage(data).then(response => {
  322. console.log(response,'隔离点数据')
  323. this.spmOptions = response.data.records
  324. })
  325. },
  326. /** 转换mars岗位数据结构 */
  327. Marsnormalizer(node) {
  328. if (node.children && !node.children.length) {
  329. delete node.children;
  330. }
  331. return {
  332. id: node.workstationId,
  333. label: node.workstationName,
  334. children: node.children,
  335. };
  336. },
  337. handleWorkstationChange(value) {
  338. this.form.entityId = value;
  339. },
  340. // 取消按钮
  341. cancel() {
  342. this.open = false
  343. this.reset()
  344. },
  345. // 表单重置
  346. reset() {
  347. this.form = {
  348. mapId: undefined,
  349. mapType: undefined,
  350. x: undefined,
  351. y: undefined,
  352. }
  353. this.resetForm('form')
  354. },
  355. /** 搜索按钮操作 */
  356. handleQuery() {
  357. this.queryParams.current = 1
  358. this.getList()
  359. },
  360. /** 重置按钮操作 */
  361. resetQuery() {
  362. this.resetForm('queryForm')
  363. this.handleQuery()
  364. },
  365. /** 新增按钮操作 */
  366. handleAdd() {
  367. this.reset()
  368. this.open = true
  369. this.title = '添加地图点位数据'
  370. },
  371. // 多选框选中数据
  372. handleSelectionChange(selection) {
  373. this.ids = selection.map(item => item.id)
  374. this.single = selection.length != 1
  375. this.multiple = !selection.length
  376. },
  377. /** 修改按钮操作 */
  378. handleUpdate(row) {
  379. this.reset()
  380. const ruleId = row.id || this.ids
  381. selectIsMapPointById(ruleId).then(response => {
  382. this.form = response.data
  383. this.open = true
  384. this.title = '修改地图点位数据'
  385. })
  386. },
  387. /** 提交按钮 */
  388. submitForm: function() {
  389. this.$refs['form'].validate(valid => {
  390. if (valid) {
  391. if (this.form.id != undefined) {
  392. updateIsMapPoint(this.form).then(response => {
  393. this.$modal.msgSuccess('修改成功')
  394. this.open = false
  395. this.getList()
  396. })
  397. } else {
  398. insertIsMapPoint(this.form).then(response => {
  399. this.$modal.msgSuccess('新增成功')
  400. this.open = false
  401. this.getList()
  402. })
  403. }
  404. }
  405. })
  406. },
  407. /** 删除按钮操作 */
  408. handleDelete(row) {
  409. debugger;
  410. const ruleIds = row.id || this.ids
  411. this.$modal.confirm('是否确认删除所选数据项?').then(function() {
  412. return deleteIsMapPointByIds(ruleIds)
  413. }).then(() => {
  414. this.getList()
  415. this.$modal.msgSuccess('删除成功')
  416. }).catch(() => {
  417. })
  418. }
  419. }
  420. }
  421. </script>