index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <div class="app-container">
  2. <el-form
  3. :model="queryParams"
  4. ref="queryForm"
  5. size="small"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="100px"
  9. >
  10. <el-form-item label="作业票名称" prop="ticketName">
  11. <el-input
  12. v-model="queryParams.ticketName"
  13. placeholder="请输入作业票名称"
  14. clearable
  15. @keyup.enter.native="handleQuery"
  16. />
  17. </el-form-item>
  18. <el-form-item label="设备/工艺" prop="machineryId">
  19. <treeselect
  20. style="width: 218px"
  21. v-model="queryParams.machineryId"
  22. :options="TechnologyOptions"
  23. :normalizer="Technologynormalizer"
  24. placeholder="选择设备工艺"
  25. />
  26. </el-form-item>
  27. <el-form-item label="岗位" prop="workstationId">
  28. <treeselect
  29. style="width: 218px"
  30. v-model="queryParams.workstationId"
  31. :options="marsOptions"
  32. :normalizer="normalizer"
  33. placeholder="选择岗位"
  34. />
  35. </el-form-item>
  36. <el-form-item label="状态" prop="ticketStatus">
  37. <el-select v-model="queryParams.ticketStatus" placeholder="状态">
  38. <el-option
  39. v-for="dict in dict.type.ticket_status"
  40. :key="dict.value"
  41. :label="dict.label"
  42. :value="dict.value"
  43. />
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item label="创建时间">
  47. <el-date-picker
  48. style="width: 218px"
  49. v-model="createTime"
  50. type="daterange"
  51. align="right"
  52. unlink-panels
  53. range-separator="至"
  54. start-placeholder="开始日期"
  55. end-placeholder="结束日期"
  56. :picker-options="pickerOptions"
  57. >
  58. </el-date-picker>
  59. </el-form-item>
  60. <el-form-item label="作业类型" prop="ticketType">
  61. <el-select
  62. v-model="queryParams.ticketType"
  63. placeholder="请选择作业类型"
  64. >
  65. <el-option
  66. v-for="dict in dict.type.ticket_type"
  67. :key="dict.value"
  68. :label="dict.label"
  69. :value="dict.value"
  70. />
  71. </el-select>
  72. </el-form-item>
  73. <el-form-item>
  74. <el-button v-no-more-click
  75. type="primary"
  76. icon="el-icon-search"
  77. size="mini"
  78. @click="handleQuery"
  79. >搜索</el-button
  80. >
  81. <el-button v-no-more-click icon="el-icon-refresh" size="mini" @click="resetQuery"
  82. >重置</el-button
  83. >
  84. </el-form-item>
  85. </el-form>
  86. <el-row :gutter="10" class="mb8">
  87. <el-col :span="1.5">
  88. <el-button v-no-more-click
  89. type="primary"
  90. plain
  91. icon="el-icon-plus"
  92. size="mini"
  93. @click="handleAdd('hasSop')"
  94. v-hasPermi="['mes:job:jobm:add']"
  95. >新增sop作业票
  96. </el-button>
  97. </el-col>
  98. <el-col :span="1.5">
  99. <el-button v-no-more-click
  100. type="primary"
  101. plain
  102. icon="el-icon-plus"
  103. size="mini"
  104. @click="handleAdd('noSop')"
  105. v-hasPermi="['mes:job:jobm:add']"
  106. >新增自定义作业票
  107. </el-button>
  108. </el-col>
  109. <el-col :span="1.5">
  110. <el-button v-no-more-click
  111. type="danger"
  112. plain
  113. icon="el-icon-delete"
  114. size="mini"
  115. :disabled="multiple"
  116. @click="handleDelete"
  117. v-hasPermi="['mes:sop:sopm:batchremove']"
  118. >批量删除
  119. </el-button>
  120. </el-col>
  121. <right-toolbar
  122. :showSearch.sync="showSearch"
  123. @queryTable="getList"
  124. ></right-toolbar>
  125. </el-row>
  126. <el-table
  127. v-loading="loading"
  128. :data="jobList"
  129. @selection-change="handleSelectionChange"
  130. >
  131. <el-table-column type="selection" width="55" align="center" />
  132. <el-table-column label="作业票名称" align="center" prop="ticketName" width="270"/>
  133. <el-table-column label="所属岗位" align="center" prop="workstationName">
  134. </el-table-column>
  135. <el-table-column label="设备工艺" align="center" prop="machineryName"></el-table-column>
  136. <el-table-column label="状态" align="center" prop="ticketStatus">
  137. <template slot-scope="scope">
  138. <dict-tag
  139. :options="dict.type.ticket_status"
  140. :value="scope.row.ticketStatus"
  141. />
  142. </template>
  143. </el-table-column>
  144. <el-table-column label="作业类型" align="center" prop="ticketType">
  145. <template slot-scope="scope">
  146. <dict-tag
  147. :options="dict.type.ticket_type"
  148. :value="scope.row.ticketType"
  149. />
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="隔离点总数" align="center" prop="pointCount">
  153. </el-table-column>
  154. <el-table-column label="创建时间" align="center" prop="createTime">
  155. </el-table-column>
  156. <el-table-column
  157. label="操作"
  158. align="center"
  159. class-name="small-padding fixed-width"
  160. >
  161. <template slot-scope="scope">
  162. <el-button v-no-more-click
  163. size="mini"
  164. type="text"
  165. icon="el-icon-edit"
  166. @click="handleUpdate(scope.row)"
  167. v-hasPermi="['mes:job:jobm:edit']"
  168. >编辑
  169. </el-button>
  170. <el-button v-no-more-click
  171. size="mini"
  172. type="text"
  173. icon="el-icon-view"
  174. @click="handleLook(scope.row)"
  175. v-hasPermi="['mes:job:jobm:progress']"
  176. >查看
  177. </el-button>
  178. <el-button v-no-more-click
  179. size="mini"
  180. type="text"
  181. icon="el-icon-delete"
  182. @click="handleDelete(scope.row)"
  183. v-hasPermi="['mes:job:jobm:remove']"
  184. >删除
  185. </el-button>
  186. </template>
  187. </el-table-column>
  188. </el-table>
  189. <pagination
  190. v-show="total > 0"
  191. :total="total"
  192. :page.sync="queryParams.current"
  193. :limit.sync="queryParams.size"
  194. @pagination="getList"
  195. />
  196. </div>
  197. </template>
  198. <script>
  199. import {
  200. getJobTicketInfo,
  201. listJobTicket,
  202. deleteIsJobTicket,
  203. } from "@/api/mes/job/job";
  204. import { genCode } from "@/api/system/autocode/rule";
  205. import { mapActions } from "vuex";
  206. import Treeselect from "@riophae/vue-treeselect";
  207. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  208. import { listMarsDept } from '@/api/system/marsdept'
  209. import { listTechnology } from '@/api/system/machinery'
  210. export default {
  211. name: "Team",
  212. components: { Treeselect },
  213. dicts: ["ticket_type", "ticket_status"],
  214. data() {
  215. return {
  216. //自动生成编码
  217. autoGenFlag: false,
  218. optType: undefined,
  219. // 遮罩层
  220. loading: true,
  221. // 选中数组
  222. ids: [],
  223. codes: [],
  224. // 非单个禁用
  225. single: true,
  226. // 非多个禁用
  227. multiple: true,
  228. // 显示搜索条件
  229. showSearch: true,
  230. // 总条数
  231. total: 0,
  232. // 班组表格数据
  233. jobList: [],
  234. //mars岗位树选项
  235. marsOptions: [],
  236. // 弹出层标题
  237. title: "",
  238. // 是否显示弹出层
  239. open: false,
  240. // 车间数据
  241. workshopList: [],
  242. // 作业区域数据
  243. workareaList: [],
  244. // 查询参数
  245. createTime: "",
  246. queryParams: {
  247. current: 1,
  248. size: 10,
  249. ticketCode: null,
  250. ticketName: null,
  251. ticketStatus: null,
  252. workshopId: null,
  253. workareaId: null,
  254. ticketType: null,
  255. startTime: "",
  256. endTime: "",
  257. },
  258. pickerOptions: {
  259. shortcuts: [
  260. {
  261. text: "最近一周",
  262. onClick(picker) {
  263. const end = new Date();
  264. const start = new Date();
  265. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  266. picker.$emit("pick", [start, end]);
  267. },
  268. },
  269. {
  270. text: "最近一个月",
  271. onClick(picker) {
  272. const end = new Date();
  273. const start = new Date();
  274. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  275. picker.$emit("pick", [start, end]);
  276. },
  277. },
  278. {
  279. text: "最近三个月",
  280. onClick(picker) {
  281. const end = new Date();
  282. const start = new Date();
  283. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  284. picker.$emit("pick", [start, end]);
  285. },
  286. },
  287. ],
  288. },
  289. // 表单参数
  290. form: {},
  291. TechnologyOptions:[],//设备工艺查询下拉
  292. //
  293. };
  294. },
  295. created() {
  296. this.getList();
  297. this.getOtherList()
  298. },
  299. methods: {
  300. ...mapActions("sopSelectPoints", [
  301. "setSopEdit",
  302. "setSopLook",
  303. "setJobLook",
  304. "selectSopPoints",
  305. "PointTableData",
  306. "PointTableData",
  307. "setMapData",
  308. 'setVisibleSopSelect'
  309. ]),
  310. // 格式化日期查询数据
  311. formatDate(date) {
  312. if (date && date instanceof Date && !isNaN(date)) {
  313. // 使用本地时间
  314. return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(
  315. 2,
  316. "0"
  317. )}-${String(date.getDate()).padStart(2, "0")}`;
  318. }
  319. return null;
  320. },
  321. /** 查询班组列表 */
  322. getList() {
  323. this.loading = true;
  324. // 格式化日期并更新queryParams
  325. if (Array.isArray(this.createTime) && this.createTime.length === 2) {
  326. this.queryParams.startTime = this.formatDate(this.createTime[0]);
  327. this.queryParams.endTime = this.formatDate(this.createTime[1]);
  328. }
  329. listJobTicket(this.queryParams).then((response) => {
  330. console.log(response, "response--作业票列表");
  331. this.jobList = response.data.records;
  332. this.total = response.data.total;
  333. this.loading = false;
  334. });
  335. },
  336. getOtherList(){
  337. const data={
  338. pasge:1,
  339. size:-1
  340. }
  341. listMarsDept(data).then(response => {
  342. this.marsOptions = this.handleTree(response.data.records,"workstationId","parentId")
  343. })
  344. listTechnology(data).then((response) => {
  345. this.TechnologyOptions = this.handleTree(response.data.records,"machineryId","parentId")
  346. })
  347. },
  348. /** 转换部门数据结构 */
  349. normalizer(node) {
  350. if (node.children && !node.children.length) {
  351. delete node.children;
  352. }
  353. return {
  354. id: node.workstationId,
  355. label: node.workstationName,
  356. children: node.children,
  357. };
  358. },
  359. Technologynormalizer(node) {
  360. if (node.children &&!node.children.length) {
  361. delete node.children;
  362. }
  363. return {
  364. id: node.machineryId,
  365. label: node.machineryName,
  366. children: node.children,
  367. };
  368. },
  369. // 取消按钮
  370. cancel() {
  371. this.open = false;
  372. this.reset();
  373. },
  374. // 表单重置
  375. reset() {
  376. this.form = {
  377. ticketCode: null,
  378. ticketName: null,
  379. ticketStatus: null,
  380. workstationId: null,
  381. workstationName: null,
  382. ticketType: null,
  383. pointCount: null,
  384. createTime: null,
  385. };
  386. this.resetForm("form");
  387. },
  388. /** 搜索按钮操作 */
  389. handleQuery() {
  390. this.queryParams.current = 1;
  391. this.getList();
  392. },
  393. /** 重置按钮操作 */
  394. resetQuery() {
  395. this.createTime = "";
  396. (this.queryParams.startTime = ""),
  397. (this.queryParams.endTime = ""),
  398. this.resetForm("queryForm");
  399. this.handleQuery();
  400. },
  401. // 多选框选中数据
  402. handleSelectionChange(selection) {
  403. this.ids = selection.map((item) => item.ticketId);
  404. this.codes = selection.map((item) => item.ticketCode);
  405. this.single = selection.length !== 1;
  406. this.multiple = !selection.length;
  407. },
  408. /** 新增按钮操作 */
  409. handleAdd(val) {
  410. if(val=='hasSop'){
  411. this.setVisibleSopSelect(true)
  412. }else {
  413. this.setVisibleSopSelect(false)
  414. }
  415. this.reset();
  416. this.open = true;
  417. this.selectSopPoints(null);
  418. this.PointTableData(null);
  419. // this.$router.push(`/mes/job/jobm/NewOperations?ticketId=null`);//黄总原来的作业票新增
  420. this.$router.push({
  421. name:'NewMarsJob'
  422. });
  423. this.title = "添加隔离点";
  424. this.optType = "add";
  425. this.setSopLook(false);
  426. this.setMapData(null);
  427. },
  428. // 查看
  429. handleLook(row) {
  430. // 设置为true表示作业票里查看不可以点击隔离点
  431. this.setSopLook(true);
  432. this.$router.push(`/mes/job/jobm/lookWork?ticketId=${row.ticketId}`);
  433. },
  434. /** 修改按钮操作 */
  435. handleUpdate(row) {
  436. console.log(row,'作业票编辑拿到的row');
  437. this.reset();
  438. const teamId = row.ticketId || this.ids;
  439. this.setSopLook(false);
  440. // 如果编辑的是带有sop模板的 就不允许点击 新增或者删除隔离点
  441. this.$router.push(
  442. `/mes/job/jobm/NewOperationsEdit?ticketId=${row.ticketId}`
  443. );
  444. getJobTicketInfo(teamId).then((response) => {
  445. this.form = response.data;
  446. this.open = true;
  447. this.title = "修改隔离点信息";
  448. this.optType = "edit";
  449. });
  450. },
  451. /** 提交按钮 */
  452. submitForm() {
  453. this.$refs["form"].validate((valid) => {
  454. if (valid) {
  455. if (this.form.teamId != null) {
  456. updateTeam(this.form).then((response) => {
  457. this.$modal.msgSuccess("修改成功");
  458. this.open = false;
  459. this.getList();
  460. });
  461. } else {
  462. addTeam(this.form).then((response) => {
  463. this.$modal.msgSuccess("新增成功");
  464. this.open = false;
  465. this.getList();
  466. });
  467. }
  468. }
  469. });
  470. },
  471. /** 删除按钮操作 */
  472. handleDelete(row) {
  473. const teamIds = row.ticketId || this.ids;
  474. const titcketCodes = row.ticketCode || this.codes;
  475. this.$modal
  476. .confirm('是否确认删除作业票编号为"' + titcketCodes + '"的数据项?')
  477. .then(function () {
  478. return deleteIsJobTicket(teamIds);
  479. })
  480. .then(() => {
  481. this.getList();
  482. this.$modal.msgSuccess("删除成功");
  483. })
  484. .catch(() => {});
  485. },
  486. /** 导出按钮操作 */
  487. handleExport() {
  488. this.download(
  489. "cal/team/export",
  490. {
  491. ...this.queryParams,
  492. },
  493. `team_${new Date().getTime()}.xlsx`
  494. );
  495. },
  496. //自动生成编码
  497. handleAutoGenChange(autoGenFlag) {
  498. if (autoGenFlag) {
  499. genCode("CAL_TEAM_CODE").then((response) => {
  500. this.form.teamCode = response;
  501. });
  502. } else {
  503. this.form.teamCode = null;
  504. }
  505. },
  506. },
  507. };
  508. </script>
  509. <style lang="scss" src="@/assets/styles/dialog-title.scss" scoped>
  510. .el-input-width {
  511. width: 380px !important;
  512. }
  513. </style>