index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="100px"
  10. @submit.native.prevent
  11. >
  12. <el-row>
  13. <el-form-item label="布局名称" prop="switchMapName">
  14. <el-input
  15. v-model="queryParams.switchMapName"
  16. placeholder="请输入布局名称"
  17. clearable
  18. @keyup.enter.native="handleQuery"
  19. />
  20. </el-form-item>
  21. <el-form-item label="岗位" prop="workstationId" >
  22. <treeselect style="width: 200px" v-model="queryParams.workstationId" :options="marsOptions" :normalizer="Marsnormalizer" placeholder="请选择岗位"/>
  23. </el-form-item>
  24. <el-form-item style="margin-left: 20px">
  25. <el-button v-no-more-click
  26. type="primary"
  27. icon="el-icon-search"
  28. size="mini"
  29. @click="handleQuery"
  30. >搜索
  31. </el-button>
  32. <el-button v-no-more-click icon="el-icon-refresh" size="mini" @click="resetQuery"
  33. >重置
  34. </el-button>
  35. </el-form-item>
  36. </el-row>
  37. </el-form>
  38. <el-row :gutter="10" class="mb8">
  39. <el-col :span="1.5">
  40. <el-button v-no-more-click
  41. type="primary"
  42. plain
  43. icon="el-icon-plus"
  44. size="mini"
  45. @click="handleAdd"
  46. v-hasPermi="['iscs:switchmap:add']"
  47. >新增
  48. </el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button v-no-more-click
  52. type="danger"
  53. plain
  54. icon="el-icon-delete"
  55. size="mini"
  56. :disabled="multiple"
  57. @click="handleDelete"
  58. v-hasPermi="['iscs:switchmap:remove']"
  59. >批量删除
  60. </el-button>
  61. </el-col>
  62. <right-toolbar
  63. :showSearch.sync="showSearch"
  64. @queryTable="getList"
  65. ></right-toolbar>
  66. </el-row>
  67. <el-table
  68. v-loading="loading"
  69. :data="repairList"
  70. @selection-change="handleSelectionChange"
  71. >
  72. <el-table-column type="selection" width="55" align="center" />
  73. <!-- <el-table-column-->
  74. <!-- label="布局编码"-->
  75. <!-- width="150px"-->
  76. <!-- align="center"-->
  77. <!-- prop="lotoCode"-->
  78. <!-- />-->
  79. <el-table-column
  80. label="布局名称"
  81. width="180px"
  82. align="center"
  83. prop="switchMapName"
  84. />
  85. <el-table-column
  86. label="排序"
  87. width="180px"
  88. align="center"
  89. prop="orderNum"
  90. />
  91. <el-table-column label="岗位" align="center" prop="workstationName" />
  92. <el-table-column label="地图名称" align="center" prop="mapName" />
  93. <el-table-column label="所属硬件序列号" align="center" prop="serialNumber"></el-table-column>
  94. <el-table-column
  95. label="布局详情"
  96. align="center"
  97. prop="create"
  98. width="200"
  99. >
  100. <template slot-scope="scope">
  101. <el-button
  102. v-no-more-click
  103. size="mini"
  104. type="text"
  105. @click="look(scope.row)"
  106. >查看
  107. </el-button>
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. label="操作"
  112. align="center"
  113. class-name="small-padding fixed-width"
  114. fixed="right"
  115. >
  116. <template slot-scope="scope">
  117. <el-button v-no-more-click
  118. size="mini"
  119. type="text"
  120. icon="el-icon-edit"
  121. @click="handleUpdate(scope.row)"
  122. v-hasPermi="['iscs:switchmap:edit','iscs:switchmap:query']"
  123. >修改
  124. </el-button>
  125. <el-button v-no-more-click
  126. size="mini"
  127. type="text"
  128. icon="el-icon-delete"
  129. @click="handleDelete(scope.row)"
  130. v-hasPermi="['iscs:switchmap:remove']"
  131. >删除
  132. </el-button>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <pagination
  137. v-show="total > 0"
  138. :total="total"
  139. :page.sync="queryParams.current"
  140. :limit.sync="queryParams.size"
  141. @pagination="getList"
  142. />
  143. <!-- 添加或修改设备维修单对话框 -->
  144. <el-dialog :title="title" :visible.sync="open" width="450px" append-to-body>
  145. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  146. <el-form-item label="布局名称" prop="switchMapName">
  147. <el-input v-model="form.switchMapName" placeholder="请输入布局名称" />
  148. </el-form-item>
  149. <el-form-item label="地图名称" prop="mapId">
  150. <el-select style="width:290px" v-model="form.mapId" placeholder="地图名称">
  151. <el-option v-for="item in this.MapOptions" :key="item.id" :label="item.name" :value="item.id">
  152. </el-option>
  153. </el-select>
  154. </el-form-item>
  155. <el-form-item label="排序" prop="orderNum">
  156. <el-input-number type="number" v-model="form.orderNum" />
  157. </el-form-item>
  158. <el-form-item label="岗位" prop="workstationId" >
  159. <treeselect v-model="form.workstationId" :options="marsOptions" :normalizer="Marsnormalizer" placeholder="选择岗位"/>
  160. </el-form-item>
  161. <el-form-item label="所属硬件" prop="serialNumber">
  162. <el-select
  163. v-model="form.serialNumber"
  164. placeholder="请选择所属硬件"
  165. clearable
  166. >
  167. <el-option
  168. v-for="dict in this.hardWareList"
  169. :key="dict.value"
  170. :label="dict.label"
  171. :value="dict.value"
  172. />
  173. </el-select>
  174. </el-form-item>
  175. <el-form-item label="布局信息" prop="map">
  176. <el-input
  177. v-model="form.map"
  178. placeholder="请输入布局信息"
  179. />
  180. </el-form-item>
  181. </el-form>
  182. <div slot="footer" class="dialog-footer">
  183. <el-button v-no-more-click type="primary" @click="submitForm">确 定</el-button>
  184. <el-button v-no-more-click @click="cancel">取 消</el-button>
  185. </div>
  186. </el-dialog>
  187. </div>
  188. </template>
  189. <script>
  190. import {
  191. getIsLotoSwitchMapPage,
  192. selectIsLotoSwitchMapById,
  193. insertIsLotoSwitchMap,
  194. updateIsLotoSwitchMap,
  195. deleteIsLotoSwitchMapBySwitchMapIds
  196. } from "@/api/mes/switchmanagement/switchmanagement";
  197. import { genCode } from "@/api/system/autocode/rule";
  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 { listTechnology } from '@/api/system/machinery'
  202. import { getIsMapPage } from '@/api/system/mapconfig'
  203. import { listHardware } from '@/api/mes/hw/hardwareinfo'
  204. export default {
  205. name: "lock",
  206. dicts: ["hardware_status"],
  207. components: { Treeselect },
  208. data() {
  209. return {
  210. autoGenFlag: false,
  211. optType: undefined,
  212. // 遮罩层
  213. loading: true,
  214. // 选中数组
  215. ids: [],
  216. codes: [],
  217. // 非单个禁用
  218. single: true,
  219. // 非多个禁用
  220. multiple: true,
  221. // 显示搜索条件
  222. showSearch: true,
  223. // mars树选项
  224. marsOptions: [],
  225. // 总条数
  226. total: 0,
  227. // 设备维修单表格数据
  228. repairList: [],
  229. // 弹出层标题
  230. title: "",
  231. // 是否显示弹出层
  232. open: false,
  233. // 查询参数
  234. createTime: "",
  235. queryParams: {
  236. current: 1,
  237. size: 10,
  238. switchMapCode: null,
  239. switchMapName: null,
  240. },
  241. // 表单参数
  242. form: {
  243. },
  244. // 地图名称 下拉
  245. MapOptions: null,
  246. hardWareList:[],//所属硬件
  247. // 表单校验
  248. rules: {
  249. switchMapCode: [
  250. { required: true, message: "布局编码不能为空", trigger: "blur" },
  251. ],
  252. switchMapName: [
  253. { required: true, message: "布局名称不能为空", trigger: "blur" },
  254. ],
  255. mapId:[
  256. { required: true, message: "地图名称不能为空", trigger: "blur" },
  257. ]
  258. },
  259. // 日期选择
  260. pickerOptions: {
  261. shortcuts: [
  262. {
  263. text: "最近一周",
  264. onClick(picker) {
  265. const end = new Date();
  266. const start = new Date();
  267. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  268. picker.$emit("pick", [start, end]);
  269. },
  270. },
  271. {
  272. text: "最近一个月",
  273. onClick(picker) {
  274. const end = new Date();
  275. const start = new Date();
  276. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  277. picker.$emit("pick", [start, end]);
  278. },
  279. },
  280. {
  281. text: "最近三个月",
  282. onClick(picker) {
  283. const end = new Date();
  284. const start = new Date();
  285. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  286. picker.$emit("pick", [start, end]);
  287. },
  288. },
  289. ],
  290. },
  291. EditId: 0, //修改判断
  292. machinerytypeOptions: [], //锁具机构类型
  293. machineryOptions:[],//查询 设备工艺数据
  294. };
  295. },
  296. created() {
  297. this.getList();
  298. this.getOtherList()
  299. },
  300. methods: {
  301. //自动生成编码
  302. handleAutoGenChange(autoGenFlag) {
  303. if (autoGenFlag) {
  304. genCode("LOTO_STATION_CODE").then((response) => {
  305. this.form.lotoCode = response;
  306. });
  307. } else {
  308. this.form.lotoCode = null;
  309. }
  310. },
  311. /** 查询设备维修单列表 */
  312. getList() {
  313. this.loading = true;
  314. // 布局数据
  315. getIsLotoSwitchMapPage(this.queryParams).then((response) => {
  316. console.log(response,'布局')
  317. this.repairList = response.data.records;
  318. this.total = response.data.total;
  319. this.loading = false;
  320. });
  321. },
  322. getOtherList(){
  323. const data={
  324. current:1,
  325. size:-1
  326. }
  327. // 获取地图类型 布局or地图
  328. getIsMapPage(data).then(response => {
  329. this.MapOptions = response.data.records
  330. })
  331. // 岗位
  332. listMarsDept(data).then(response => {
  333. this.marsOptions = this.handleTree(response.data.records,"workstationId","parentId")
  334. })
  335. // 设备/工艺
  336. listTechnology(data).then((response) => {
  337. const data=response.data.records.filter((item) =>item.machineryType=='工艺')
  338. this.machineryOptions = this.handleTree(
  339. data,
  340. "machineryId",
  341. "parentId"
  342. );
  343. });
  344. listHardware(data).then((response) => {
  345. this.hardWareList = response.data.records.map((item) => {
  346. return {
  347. value: item.serialNumber,
  348. label: item.hardwareName,
  349. };
  350. });
  351. })
  352. },
  353. /** 转换部门数据结构 */
  354. Marsnormalizer(node) {
  355. if (node.children && !node.children.length) {
  356. delete node.children
  357. }
  358. return {
  359. id: node.workstationId,
  360. label: node.workstationName,
  361. children: node.children
  362. }
  363. },
  364. // 取消按钮
  365. cancel() {
  366. this.open = false;
  367. this.reset();
  368. },
  369. // 表单重置
  370. reset() {
  371. this.form = {
  372. lotoName: null,
  373. workstationId: null,
  374. orderNum: null,
  375. map:null,
  376. lotoSerialNumber: null,
  377. };
  378. this.autoGenFlag = false;
  379. this.resetForm("form");
  380. },
  381. /** 搜索按钮操作 */
  382. handleQuery() {
  383. this.queryParams.current = 1;
  384. this.getList();
  385. },
  386. /** 重置按钮操作 */
  387. resetQuery() {
  388. this.queryParams.switchMapName = "";
  389. this.queryParams.switchMapId = "";
  390. this.resetForm("queryForm");
  391. this.handleQuery();
  392. },
  393. // 多选框选中数据
  394. handleSelectionChange(selection) {
  395. this.ids = selection.map((item) => item.switchMapId);
  396. this.codes = selection.map((item) => item.switchMapName);
  397. this.single = selection.length !== 1;
  398. this.multiple = !selection.length;
  399. },
  400. /** 新增按钮操作 */
  401. handleAdd() {
  402. this.reset();
  403. this.open = true;
  404. this.EditId = null;
  405. this.title = "新增布局信息";
  406. },
  407. /** 修改按钮操作 */
  408. handleUpdate(row) {
  409. this.reset();
  410. this.EditId = row.switchMapId || this.ids;
  411. selectIsLotoSwitchMapById(this.EditId).then((response) => {
  412. this.form = response.data;
  413. this.open = true;
  414. this.title = "修改布局信息";
  415. });
  416. },
  417. /** 提交按钮 */
  418. submitForm() {
  419. this.$refs["form"].validate((valid) => {
  420. if (valid) {
  421. if (this.EditId != null) {
  422. updateIsLotoSwitchMap(this.form).then((response) => {
  423. this.$modal.msgSuccess("修改成功");
  424. this.open = false;
  425. this.getList();
  426. });
  427. } else {
  428. // console.log(this.form, "form");
  429. insertIsLotoSwitchMap(this.form).then((response) => {
  430. this.$modal.msgSuccess("新增成功");
  431. this.open = false;
  432. this.EditId = null;
  433. this.getList();
  434. });
  435. }
  436. }
  437. });
  438. },
  439. // 地图预览
  440. look(row) {
  441. console.log(row, "row预览");
  442. const data = row.switchMapId;
  443. this.$router.push(`/mes/dv/switchmanagement/index/LookDetail?switchMapId=${data}`);
  444. // this.dialogVisibleMap = true; // 显示地图预览弹框
  445. },
  446. /** 删除按钮操作 */
  447. handleDelete(row) {
  448. const repairIds = row.switchMapId || this.ids;
  449. const repairCodes = row.switchMapName || this.codes;
  450. this.$modal
  451. .confirm('是否确认删除所选数据项?')
  452. .then(function () {
  453. return deleteIsLotoSwitchMapBySwitchMapIds(repairIds);
  454. })
  455. .then(() => {
  456. this.getList();
  457. this.$modal.msgSuccess("删除成功");
  458. })
  459. .catch(() => {});
  460. },
  461. },
  462. };
  463. </script>
  464. <style scoped>
  465. .imgstatus {
  466. position: relative;
  467. top: 1px;
  468. left: 0px;
  469. }
  470. /deep/ .el-radio__inner {
  471. border-radius: 2px;
  472. }
  473. /deep/ .el-radio__input.is-checked .el-radio__inner::after {
  474. content: "";
  475. width: 8px;
  476. height: 3px;
  477. border: 1px solid white;
  478. border-top: transparent;
  479. border-right: transparent;
  480. text-align: center;
  481. display: block;
  482. position: absolute;
  483. top: 3px;
  484. left: 2px;
  485. transform: rotate(-45deg);
  486. border-radius: 0pc;
  487. background: none;
  488. }
  489. </style>