index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. >
  11. <el-form-item label="工作区域编码" prop="workareaCode">
  12. <el-input
  13. v-model="queryParams.workareaCode"
  14. placeholder="请输入工作区域编码"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="工作区域名称" prop="workareaName">
  20. <el-input
  21. v-model="queryParams.workareaName"
  22. placeholder="请输入隔离点名称"
  23. clearable
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="工作区域类型" prop="workareaType">
  28. <el-input
  29. v-model="queryParams.workareaType"
  30. placeholder="请输入工作区域类型"
  31. clearable
  32. @keyup.enter.native="handleQuery"
  33. />
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button
  37. type="primary"
  38. icon="el-icon-search"
  39. size="mini"
  40. @click="handleQuery"
  41. >搜索</el-button
  42. >
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  44. >重置</el-button
  45. >
  46. </el-form-item>
  47. </el-form>
  48. <el-row :gutter="10" class="mb8">
  49. <el-col :span="1.5">
  50. <el-button
  51. type="primary"
  52. plain
  53. icon="el-icon-plus"
  54. size="mini"
  55. @click="handleAdd"
  56. v-hasPermi="['mes:md:waa:add']"
  57. >新增
  58. </el-button>
  59. </el-col>
  60. <!-- <el-col :span="1.5">-->
  61. <!-- <el-button-->
  62. <!-- type="success"-->
  63. <!-- plain-->
  64. <!-- icon="el-icon-edit"-->
  65. <!-- size="mini"-->
  66. <!-- :disabled="single"-->
  67. <!-- @click="handleUpdate"-->
  68. <!-- v-hasPermi="['mes:cal:team:edit']"-->
  69. <!-- >修改</el-button>-->
  70. <!-- </el-col>-->
  71. <el-col :span="1.5">
  72. <el-button
  73. type="danger"
  74. plain
  75. icon="el-icon-delete"
  76. size="mini"
  77. :disabled="multiple"
  78. @click="handleDelete"
  79. v-hasPermi="['mes:md:waa:batchremove']"
  80. >批量删除
  81. </el-button>
  82. </el-col>
  83. <!-- <el-col :span="1.5">-->
  84. <!-- <el-button-->
  85. <!-- type="warning"-->
  86. <!-- plain-->
  87. <!-- icon="el-icon-download"-->
  88. <!-- size="mini"-->
  89. <!-- @click="handleExport"-->
  90. <!-- v-hasPermi="['mes:cal:team:export']"-->
  91. <!-- >导出</el-button>-->
  92. <!-- </el-col>-->
  93. <right-toolbar
  94. :showSearch.sync="showSearch"
  95. @queryTable="getList"
  96. ></right-toolbar>
  97. </el-row>
  98. <el-table
  99. v-loading="loading"
  100. :data="workareaList"
  101. @selection-change="handleSelectionChange"
  102. >
  103. <el-table-column type="selection" width="55" align="center" />
  104. <el-table-column label="工作区域Id" align="center" prop="workareaId">
  105. <template slot-scope="scope">
  106. <el-button
  107. type="text"
  108. @click="handleView(scope.row)"
  109. v-hasPermi="['mes:md:waa:query']"
  110. >{{ scope.row.workareaId }}
  111. </el-button>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="工作区域编码" align="center" prop="workareaCode">
  115. <template slot-scope="scope">
  116. <el-button
  117. type="text"
  118. @click="handleView(scope.row)"
  119. v-hasPermi="['mes:md:waa:query']"
  120. >{{ scope.row.workareaCode }}
  121. </el-button>
  122. </template>
  123. </el-table-column>
  124. <el-table-column
  125. label="工作区域名称"
  126. align="center"
  127. prop="workareaName"
  128. />
  129. <el-table-column
  130. label="工作区域类型"
  131. align="center"
  132. prop="workareaType"
  133. />
  134. <el-table-column label="所属车间" align="center" prop="workshopName" />
  135. <!-- <el-table-column label="状态" align="center" prop="calendarType">-->
  136. <!-- <template slot-scope="scope">-->
  137. <!-- <dict-tag :options="dict.type.mes_calendar_type" :value="scope.row.calendarType"/>-->
  138. <!-- </template>-->
  139. <!-- </el-table-column>-->
  140. <el-table-column label="地图" align="center" prop="map">
  141. <!-- <template slot-scope="scope">
  142. {{ scope.row.map }}
  143. </template> -->
  144. <template slot-scope="scope">
  145. <el-button size="mini" type="text" @click="look(scope.row)"
  146. >预览
  147. </el-button>
  148. </template>
  149. </el-table-column>
  150. <!-- <el-table-column label="备注" align="center" prop="remark">-->
  151. <!-- </el-table-column>-->
  152. <el-table-column
  153. label="操作"
  154. align="center"
  155. class-name="small-padding fixed-width"
  156. >
  157. <template slot-scope="scope">
  158. <el-button
  159. size="mini"
  160. type="text"
  161. icon="el-icon-edit"
  162. @click="handleUpdate(scope.row)"
  163. v-hasPermi="['mes:md:waa:edit']"
  164. >编辑
  165. </el-button>
  166. <el-button
  167. size="mini"
  168. type="text"
  169. icon="el-icon-delete"
  170. @click="handleDelete(scope.row)"
  171. v-hasPermi="['mes:md:waa:remove']"
  172. >删除
  173. </el-button>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. <pagination
  178. v-show="total > 0"
  179. :total="total"
  180. :page.sync="queryParams.current"
  181. :limit.sync="queryParams.size"
  182. @pagination="getList"
  183. />
  184. <!-- 添加或修改班组对话框 -->
  185. <el-dialog :visible.sync="open" width="660px" append-to-body>
  186. <div slot="title" class="dialog-title">
  187. <i></i>
  188. <span class="title">{{ title }}</span>
  189. </div>
  190. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  191. <el-form-item label="区域名称" prop="workareaName">
  192. <el-input
  193. style="width: 318px"
  194. v-model="form.workareaName"
  195. placeholder="请输入区域名称"
  196. />
  197. </el-form-item>
  198. <el-row>
  199. <el-col :span="13">
  200. <el-form-item label="区域编码" prop="workareaCode">
  201. <el-input
  202. v-model="form.workareaCode"
  203. placeholder="请输入区域编码"
  204. />
  205. </el-form-item>
  206. </el-col>
  207. <el-col :span="5">
  208. <el-form-item label-width="80">
  209. <el-switch
  210. v-model="autoGenFlag"
  211. active-color="#13ce66"
  212. active-text="自动生成"
  213. @change="handleAutoGenChange(autoGenFlag)"
  214. v-if="optType != 'view'"
  215. >
  216. </el-switch>
  217. </el-form-item>
  218. </el-col>
  219. </el-row>
  220. <el-form-item label="区域类型" prop="workareaType">
  221. <el-input
  222. style="width: 318px"
  223. v-model="form.workareaType"
  224. placeholder="请输入区域类型"
  225. />
  226. </el-form-item>
  227. <el-form-item label="所属车间" prop="workshopId">
  228. <el-select
  229. style="width: 318px"
  230. v-model="form.workshopId"
  231. placeholder="请选择所属车间"
  232. >
  233. <el-option
  234. v-for="dict in this.WorkShopListOptions"
  235. :key="dict.key"
  236. :label="dict.label"
  237. :value="dict.value"
  238. />
  239. </el-select>
  240. </el-form-item>
  241. <el-form-item label="地图" prop="map">
  242. <el-input
  243. style="width: 318px"
  244. v-model="form.map"
  245. placeholder="请输入地图"
  246. />
  247. <!-- <ImageUpload :limit="1" :value="form.map" :fileSize="5" @onUploaded="handleImgUplaoded" @onRemoved="handleImgRemoved" ></ImageUpload>-->
  248. </el-form-item>
  249. <!-- <el-form-item label="备注" prop="remark">-->
  250. <!-- <el-input style="width: 318px" type="textarea" v-model="form.remark" placeholder="请输入备注" />-->
  251. <!-- </el-form-item>-->
  252. </el-form>
  253. <div slot="footer" class="dialog-footer">
  254. <el-button type="primary" @click="cancel" v-if="optType == 'view'"
  255. >返回</el-button
  256. >
  257. <el-button type="primary" @click="submitForm" v-else>确 定</el-button>
  258. <el-button @click="cancel">取 消</el-button>
  259. </div>
  260. </el-dialog>
  261. </div>
  262. </template>
  263. <script>
  264. import {
  265. listWorkarea,
  266. getWorkareaInfo,
  267. addWorkarea,
  268. updateWorkarea,
  269. delWorkarea,
  270. listAllWorkshop,
  271. } from "@/api/mes/wa/workarea";
  272. import { genCode } from "@/api/system/autocode/rule";
  273. import { mapActions, mapState } from "vuex";
  274. export default {
  275. name: "index",
  276. dicts: ["mes_calendar_type"],
  277. data() {
  278. return {
  279. //自动生成编码
  280. autoGenFlag: false,
  281. optType: undefined,
  282. // 遮罩层
  283. loading: true,
  284. // 选中数组
  285. ids: [],
  286. // 非单个禁用
  287. single: true,
  288. // 非多个禁用
  289. multiple: true,
  290. // 显示搜索条件
  291. showSearch: true,
  292. // 地图预览弹框
  293. dialogVisibleMap: false,
  294. // 总条数
  295. total: 0,
  296. // 班组表格数据
  297. workareaList: [],
  298. // 弹出层标题
  299. title: "",
  300. // 是否显示弹出层
  301. open: false,
  302. // 查询参数
  303. queryParams: {
  304. current: 1,
  305. size: 10,
  306. workareaCode: null,
  307. workareaName: null,
  308. workareaType: null,
  309. },
  310. // 表单参数
  311. form: {},
  312. WorkShopListOptions: null, //所属车间下拉数据
  313. EditId: null, //判断是否是编辑弹框的值
  314. // 表单校验
  315. rules: {
  316. workareaCode: [
  317. { required: true, message: "区域编号不能为空", trigger: "blur" },
  318. ],
  319. workareaName: [
  320. { required: true, message: "区域名称不能为空", trigger: "blur" },
  321. ],
  322. workareaType: [
  323. { required: true, message: "清选择区域类型", trigger: "blur" },
  324. ],
  325. },
  326. };
  327. },
  328. created() {
  329. this.getList();
  330. },
  331. methods: {
  332. /** 查询班组列表 */
  333. getList() {
  334. this.loading = true;
  335. listWorkarea(this.queryParams).then((response) => {
  336. console.log(response, "获取工作取区域allList ");
  337. this.workareaList = response.data.records;
  338. this.total = response.data.total;
  339. this.loading = false;
  340. });
  341. // 获取所有车间信息
  342. listAllWorkshop().then((response) => {
  343. console.log(response, "车间信息");
  344. this.WorkShopListOptions = response.data.map((item) => {
  345. return {
  346. label: item.workshopName,
  347. value: item.workshopId,
  348. key: item.workshopCode,
  349. };
  350. });
  351. });
  352. },
  353. // 取消按钮
  354. cancel() {
  355. this.open = false;
  356. this.reset();
  357. },
  358. // 表单重置
  359. reset() {
  360. this.form = {
  361. remark: null,
  362. map: null,
  363. workareaCode: null,
  364. workareaId: null,
  365. workareaName: null,
  366. workareaType: null,
  367. workshopId: null,
  368. };
  369. this.autoGenFlag = false;
  370. this.resetForm("form");
  371. },
  372. /** 搜索按钮操作 */
  373. handleQuery() {
  374. this.queryParams.current = 1;
  375. this.getList();
  376. },
  377. /** 重置按钮操作 */
  378. resetQuery() {
  379. this.queryParams = {
  380. current: 1,
  381. size: 10,
  382. workareaCode: null,
  383. workareaName: null,
  384. workareaType: null,
  385. };
  386. this.resetForm("queryForm");
  387. this.handleQuery();
  388. },
  389. // 多选框选中数据
  390. handleSelectionChange(selection) {
  391. this.ids = selection.map((item) => item.workareaId);
  392. this.single = selection.length !== 1;
  393. this.multiple = !selection.length;
  394. },
  395. /** 新增按钮操作 */
  396. handleAdd() {
  397. this.reset();
  398. this.open = true;
  399. this.title = "添加工作区域";
  400. this.optType = "add";
  401. this.EditId = null;
  402. },
  403. // 查询明细按钮操作
  404. handleView(row) {
  405. this.reset();
  406. this.EditId = row.workareaId || this.ids;
  407. getWorkareaInfo(this.EditId).then((response) => {
  408. this.form = response.data;
  409. this.open = true;
  410. this.title = "查看工作区域";
  411. this.optType = "view";
  412. });
  413. },
  414. /** 修改按钮操作 */
  415. handleUpdate(row) {
  416. this.reset();
  417. this.EditId = row.workareaId || this.ids;
  418. console.log(row, "row");
  419. getWorkareaInfo(this.EditId).then((response) => {
  420. console.log(response, "获取单条工作区域数据");
  421. this.form = response.data;
  422. this.open = true;
  423. this.title = "修改工作区域信息";
  424. this.optType = "edit";
  425. });
  426. },
  427. /** 提交按钮 */
  428. submitForm() {
  429. this.$refs["form"].validate((valid) => {
  430. if (valid) {
  431. if (this.EditId != null) {
  432. updateWorkarea(this.form).then((response) => {
  433. this.$modal.msgSuccess("修改成功");
  434. this.open = false;
  435. this.getList();
  436. });
  437. } else {
  438. addWorkarea(this.form).then((response) => {
  439. this.$modal.msgSuccess("新增成功");
  440. this.open = false;
  441. this.EditId = null;
  442. this.getList();
  443. });
  444. }
  445. }
  446. });
  447. },
  448. /** 删除按钮操作 */
  449. handleDelete(row) {
  450. const teamIds = row.workareaId || this.ids;
  451. this.$modal
  452. .confirm('是否确认删除工作区域编号为"' + teamIds + '"的数据项?')
  453. .then(function () {
  454. return delWorkarea(teamIds);
  455. })
  456. .then(() => {
  457. this.getList();
  458. this.$modal.msgSuccess("删除成功");
  459. })
  460. .catch(() => {});
  461. },
  462. // 地图预览
  463. look(row) {
  464. console.log(row, "row预览");
  465. const data = row.workareaId;
  466. this.$router.push(`/mes/md/workarea/index/MapData?workareaId=${data}`);
  467. // this.dialogVisibleMap = true; // 显示地图预览弹框
  468. },
  469. updateMapData(selectedPoints) {
  470. // Sync mapData with the selected points in MapData
  471. this.mapData = selectedPoints;
  472. },
  473. // 地图弹框关闭按钮
  474. handleClose() {
  475. this.dialogVisibleMap = false;
  476. },
  477. //自动生成编码
  478. handleAutoGenChange(autoGenFlag) {
  479. if (autoGenFlag) {
  480. genCode("WORKAREA_CODE").then((response) => {
  481. this.form.workareaCode = response;
  482. });
  483. } else {
  484. this.form.workareaCode = null;
  485. }
  486. },
  487. },
  488. };
  489. </script>
  490. <style lang="scss" src="@/assets/styles/dialog-title.scss" scoped>
  491. .el-input-width {
  492. width: 380px !important;
  493. }
  494. </style>