index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <div class="index_box">
  3. <div class="content_box">
  4. <!-- @tab-click="handleClick" -->
  5. <!-- 工序名称 -->
  6. <!-- <Search></Search> -->
  7. <div class="content_box_tab">
  8. <el-input style="width: 180px" clearable v-model="name" placeholder="请输入筛选项" @input="seekInput" />
  9. <el-tabs v-model="activeName" type="card" stretch @tab-click="tabClickValue">
  10. <el-tab-pane label="工序" name="0">
  11. <el-tree :data="produceTaskList" :props="defaultProps" node-key="id" :highlight-current="true"
  12. @node-click="handleNodeClick">
  13. </el-tree>
  14. <!--
  15. v-loading="treeLoading"
  16. :node-key="nodeKey"
  17. ref="tree"
  18. :highlight-current="true"
  19. :expand-on-click-node="false"
  20. @node-click="handleNodeClick"
  21. v-bind="$attrs"
  22. :default-expand-all="defaultExpandAll" -->
  23. </el-tab-pane>
  24. <el-tab-pane label="工位" name="second">
  25. <!-- <AssetTree @handleNodeClick="handleNodeClickNew" @setRootId="setRootId" id="0" :paramsType="'type'"
  26. ref="treeList" eqDevice="sb" /> -->
  27. <el-tree :data="factoryworkstationList" :props="defaultPropsTow" node-key="id" :highlight-current="true"
  28. @node-click="handleNodeClick">
  29. </el-tree>
  30. </el-tab-pane>
  31. </el-tabs>
  32. </div>
  33. <div style="width: calc(100% - 220px);">
  34. <div class="seek-list" style="background-color: #157A2C;">
  35. <div>
  36. <el-input style="width: 180px;margin-right: 5px;" clearable v-model="keyWord" placeholder="请输入关键字" />
  37. <!-- <el-input style="width: 180px" clearable v-model="taskName" placeholder="请输入工序进度" /> -->
  38. <!-- -->
  39. <el-button size="mini" type="primary" style="margin: 0 5px" @click="handleSearch">查询</el-button>
  40. </div>
  41. <div style="width: 55%;color: #fff; display: flex;justify-content: space-between;">
  42. <div>
  43. <b style="margin-right:50px;">当前工序:{{ title }}</b>
  44. <b>下道工序:{{ title1 }}</b>
  45. </div>
  46. <div>
  47. 操作员:{{ info.name }}
  48. </div>
  49. </div>
  50. </div>
  51. <ele-split-layout space="0px" width="45%" :resizable="true" :min-size="200" :max-size="-200" :left-style="{
  52. overflow: 'hidden',
  53. width: '100%'
  54. }" :right-style="{ overflow: 'hidden' }" :responsive="false" style="height: calc(100vh - 70px - 50px - 90px)">
  55. <!-- 左侧 工单列表 -->
  56. <div class="left_main">
  57. <div class="top">
  58. <!-- /工单列表 -->
  59. <produceOrder @workSelect="workSelect" @rowClick="rowClick" ref="produceOrder" @getTaskName="getTaskName">
  60. </produceOrder>
  61. </div>
  62. <!-- <div class="bottom">
  63. <productionResource :BomObj="BomObj"></productionResource>
  64. </div> -->
  65. </div>
  66. <!-- 右侧 详情 -->
  67. <template v-slot:content>
  68. <div class="right_main">
  69. <!-- 领料 -->
  70. <div v-if="operationType == 'pick'">
  71. <pickDetails ref="pickListRef" @pickAdd="pickAdd"></pickDetails>
  72. </div>
  73. <div v-if="operationType == 'feed'">
  74. <!-- 投料 -->
  75. <feeding :workListIds="workListIds"></feeding>
  76. </div>
  77. <div v-if="operationType == 'job'">
  78. <!-- // 报工列表 入库 -->
  79. <warehousing v-if="taskObj.id == -1" :workListIds="workListIds" ref="wareRef"></warehousing>
  80. <!-- // 设备 入库 -->
  81. <!-- 普通报工 -->
  82. <jobBooking v-else :workListIds="workListIds" ref="jobRef"></jobBooking>
  83. </div>
  84. <!-- 质检工序 -->
  85. <div v-if="operationType == 'inspection'">
  86. <inspection :workListIds="workListIds" ref="inspectionRef"></inspection>
  87. </div>
  88. <!-- 委外 -->
  89. <div v-if="operationType == 'Outsourcing' && isType == '3'" class="right_main_box">
  90. <outsourcing :outsourceFormVal="outsourceForm" @changePlugIn="changePlugIn" v-if="isStep"></outsourcing>
  91. <!-- -->
  92. <outsourceList :outsourceFormVal="outObj" @closeForm="closeForm" v-else></outsourceList>
  93. </div>
  94. </div>
  95. </template>
  96. </ele-split-layout>
  97. <footBtn @footBtn="footBtn" :type="type" style="background: rgba(223, 250, 222,0.6);padding: 10px;"></footBtn>
  98. </div>
  99. <!-- <footBtn @footBtn="footBtn"></footBtn> -->
  100. </div>
  101. <!--领料弹框 -->
  102. <picking v-if="pickingShow" @close="pickingClose" :workListIds="workListIds"></picking>
  103. <!-- 工艺文件 -->
  104. <wokePopup ref="wokePopupRef"></wokePopup>
  105. <!-- :workListIds="workListIds" :taskId="taskObj.id" -->
  106. </div>
  107. </template>
  108. <script>
  109. import Search from './components/search.vue';
  110. import footBtn from './components/footBtn.vue';
  111. import produceOrder from './components/produceOrder.vue';
  112. import productionResource from './components/productionResource/index.vue';
  113. import outsourcing from './components/outsourcing/index.vue';
  114. import picking from './components/picking/index.vue';
  115. import wokePopup from './components/picking/wokePopup.vue';
  116. import inspection from './components/inspection/index.vue';
  117. import pickDetails from './components/picking/details.vue';
  118. import AssetTree from '@/components/AssetTree/joobIndex.vue';
  119. import feeding from './components/feeding/index.vue';
  120. import jobBooking from './components/jobBooking/index.vue';
  121. import warehousing from './components/warehousing/index.vue';
  122. import outsourceList from './components/outsourcing/outsourceList.vue';
  123. import { getByTaskId, pcCheckOutsource, getTaskInstanceById, checkOutsourceMaterial, listTask, factoryworkstationPage, nextTask } from '@/api/produce/index';
  124. export default {
  125. components: {
  126. Search,
  127. footBtn,
  128. wokePopup,
  129. produceOrder,
  130. productionResource,
  131. outsourcing,
  132. picking,
  133. pickDetails,
  134. outsourceList,
  135. feeding,
  136. AssetTree,
  137. jobBooking,
  138. inspection,
  139. warehousing
  140. },
  141. data() {
  142. return {
  143. name: '',
  144. activeName: '0',
  145. taskName: '',
  146. keyWord: '',//搜索
  147. title: '',
  148. type: '',
  149. loading: false,
  150. operationType: null,
  151. workListIds: [],
  152. factoryworkstationList: [],
  153. title1: '',
  154. arr: [],
  155. arrTow:[],
  156. produceTaskList: [],
  157. isType: '',
  158. isStep: true,
  159. outsourceForm: {},
  160. outObj: {},
  161. pickingShow: false,
  162. wokePopup: false,
  163. BomObj: {},
  164. defaultProps: {
  165. children: 'children',
  166. label: 'newName'
  167. },
  168. defaultPropsTow: {
  169. children: 'children',
  170. label: 'name',
  171. value: 'code'
  172. }
  173. };
  174. },
  175. computed: {
  176. taskObj() {
  177. return this.$store.state.user.taskObj;
  178. },
  179. info() {
  180. return this.$store.state.user.info;
  181. }
  182. },
  183. created() {
  184. this.init()
  185. this.getTaskList();
  186. this.getFactoryworkstationPageList();
  187. this.operationType = null;
  188. this.workListIds = [];
  189. },
  190. methods: {
  191. tabClickValue(){
  192. this.name ='';
  193. this.seekInput()
  194. },
  195. // 前端筛选
  196. seekInput() {
  197. // console.log(activeName);
  198. if (this.activeName == '0') {
  199. if (!this.name) return (this.produceTaskList = this.arr);
  200. this.produceTaskList = this.produceTaskList.filter(item => {
  201. return item.name.indexOf(this.name) > -1
  202. })
  203. } else {
  204. if (!this.name) return (this.factoryworkstationList = this.arrTow);
  205. this.factoryworkstationList = this.factoryworkstationList.filter(item => {
  206. return item.name.indexOf(this.name) > -1
  207. })
  208. }
  209. },
  210. // 折叠悬浮中样式调整
  211. init() {
  212. this.$store.dispatch('theme/setCollapse', true);
  213. },
  214. async getTaskName(value) {
  215. if (value.length > 0) {
  216. let res = await nextTask({
  217. taskId: this.taskObj.id,
  218. workOrderIds: value.map(item => item.id)
  219. })
  220. this.title1 = res.data.map(item => item.taskTypeName).toString()
  221. } else {
  222. this.title1 = ''
  223. }
  224. },
  225. handleSearch() {
  226. let obj = {
  227. keyWord: this.keyWord,
  228. taskName: this.taskName
  229. }
  230. this.$refs.produceOrder.handleSearch(obj);
  231. //handleSearch(this.code);
  232. },
  233. handleNodeClickNew(info) {
  234. console.log(info, '999');
  235. // this.current = info;
  236. let current = { id: info.id };
  237. this.$store.commit('user/currentObj', current);
  238. },
  239. setRootId(id) {
  240. this.rootId = id;
  241. },
  242. // 点击工序
  243. handleNodeClick(data) {
  244. console.log(data);
  245. let obj = {
  246. '1': `${data.workCenterName}-${data.name}(普通工序)`,
  247. '3': `${data.workCenterName}-${data.name}(质检工序)`,
  248. '4': `${data.workCenterName}-${data.name}(包装工序)`,
  249. '5': `${data.workCenterName}-${data.name}(入库工序)`,
  250. '6': `${data.workCenterName}-${data.name}(质检工序)`
  251. }
  252. this.title = obj[data.type] || '';
  253. this.type = data.type;
  254. let taskObj = {};
  255. taskObj = this.produceTaskList.find((item) => item.id === data.id);
  256. this.$store.commit('user/setTaskObj', taskObj);
  257. },
  258. // 获取工序列表
  259. getTaskList() {
  260. listTask().then((res) => {
  261. res.map(v => {
  262. v.newName = `${v.workCenterName}-${v.name}`
  263. })
  264. this.produceTaskList = res;
  265. this.arr = JSON.parse(JSON.stringify(this.produceTaskList));
  266. // newName
  267. });
  268. },
  269. // 获取工位
  270. getFactoryworkstationPageList() {
  271. factoryworkstationPage({ pageNum: 1, size: 99999999 }).then((res) => {
  272. console.log(res, 'res');
  273. this.factoryworkstationList = res.list;
  274. this.arrTow = JSON.parse(JSON.stringify(this.factoryworkstationList));
  275. // newName
  276. });
  277. },
  278. closeForm() {
  279. this.isStep = true;
  280. },
  281. // 切换组件
  282. async changePlugIn(e) {
  283. this.outObj = e;
  284. let req = {
  285. taskId: e.taskId,
  286. taskIds: e.taskIds,
  287. workOrderId: e.workOrderId
  288. }
  289. const res = await checkOutsourceMaterial(req);
  290. this.outObj = { ...this.outObj, ...res.data, ...this.outsourceForm };
  291. this.isStep = false;
  292. },
  293. workSelect(data) {
  294. this.isStep = true;
  295. this.operationType = null;
  296. this.workListIds = data.ids;
  297. },
  298. pickingWokeClose() {
  299. this.wokePopup = false;
  300. },
  301. footBtn(t) {
  302. this.operationType = t;
  303. if (
  304. Object.keys(this.$store.state.user.taskObj).length === 0 &&
  305. this.$store.state.user.taskObj.constructor === Object
  306. ) {
  307. this.$message.warning('请选择工序');
  308. return false;
  309. }
  310. if (['pick', 'feed', 'job'].includes(t)) {
  311. if (this.workListIds.length == 0) {
  312. this.$message.warning('请选择工单列表');
  313. return false;
  314. }
  315. }
  316. if (t == 'pick') {
  317. this.$nextTick(() => {
  318. this.$refs.pickListRef.getList(this.workListIds);
  319. });
  320. }
  321. // 工艺路线
  322. if (t === 'work') {
  323. let req = {
  324. taskId: this.taskObj.id,
  325. workOrderId: this.workListIds[0]
  326. }
  327. this.$refs.wokePopupRef.open(req);
  328. }
  329. if (t == 'feed') {
  330. }
  331. // 委外
  332. if (t == 'Outsourcing') {
  333. if (this.workListIds.length > 1) {
  334. return this.$message.warning('委外工序只能选择一个工单!');
  335. } else if (this.workListIds.length < 1)
  336. return this.$message.warning('请选择工单!');
  337. else {
  338. // /
  339. this.handOutsource(this.workListIds[0]);
  340. }
  341. }
  342. },
  343. handOutsource(workOrderId) {
  344. console.log(this.taskObj, workOrderId);
  345. // return
  346. let param = {
  347. taskId: this.taskObj.id,
  348. workOrderId: workOrderId,
  349. }
  350. pcCheckOutsource(param).then(res => {
  351. this.outsourceForm = {
  352. ...res.data,
  353. }
  354. this.outsourceForm.name = this.taskObj.name + '委外'
  355. console.log(res, 'res');
  356. if (res.data.outsource) {
  357. this.isType = '3';
  358. this.getTaskInstanceByIdFn(workOrderId)
  359. } else {
  360. return this.$message.warning('此工序不能委外');
  361. }
  362. })
  363. },
  364. //获取工单列表
  365. getTaskInstanceByIdFn(workOrderId) {
  366. getTaskInstanceById(workOrderId).then((res) => {
  367. console.log(res, 'res');
  368. let { data } = res;
  369. if (data.length) {
  370. data = data.filter(item => item.type == 1);
  371. let arr = data.findIndex(item => item.sourceTaskId == this.taskObj.id)
  372. console.log(arr);
  373. if (arr != -1) {
  374. data.splice(0, arr + 1)
  375. }
  376. this.$set(this.outsourceForm, 'newStepsList', data)
  377. }
  378. })
  379. },
  380. pickAdd() {
  381. this.pickingShow = true;
  382. },
  383. // 关闭领料弹窗
  384. pickingClose(val) {
  385. if (val) {
  386. this.$nextTick(() => {
  387. this.$refs.pickListRef.getList(this.workListIds);
  388. });
  389. }
  390. this.pickingShow = false;
  391. },
  392. rowClick(row, taskId) {
  393. if (taskId) {
  394. let params = {
  395. categoryId: row.categoryId,
  396. taskId: taskId
  397. };
  398. getByTaskId(params).then((res) => {
  399. this.BomObj = res.data;
  400. this.$forceUpdate();
  401. });
  402. }
  403. }
  404. },
  405. mounted() {
  406. this.$nextTick(() => {
  407. const targetElements =
  408. document.getElementsByClassName('ele-admin-tabs');
  409. if (targetElements.length > 0) {
  410. // 遍历所有具有 'ele-admin-tabs' 类的元素
  411. Array.from(targetElements).forEach((element) => {
  412. // 对每个元素添加 'new-ele-admin-tabs' 类
  413. element.classList.add('new-ele-admin-tabs');
  414. });
  415. }
  416. });
  417. },
  418. destroyed() {
  419. this.$nextTick(() => {
  420. const targetElements =
  421. document.getElementsByClassName('ele-admin-tabs');
  422. if (targetElements.length > 0) {
  423. Array.from(targetElements).forEach((element) => {
  424. element.classList.remove('new-ele-admin-tabs');
  425. });
  426. }
  427. });
  428. }
  429. };
  430. </script>
  431. <style>
  432. .content_box {
  433. display: flex;
  434. }
  435. .content_box_tab {
  436. width: 220px;
  437. padding: 5px;
  438. height: calc(100vh - 73px);
  439. background-color: #fff;
  440. overflow-y: auto;
  441. }
  442. .footBtn {
  443. position: absolute;
  444. bottom: 20px;
  445. left: 0;
  446. }
  447. .new-ele-admin-tabs {
  448. display: none !important;
  449. }
  450. .c_title {
  451. color: #157a2c;
  452. font-size: 16px;
  453. font-weight: bold;
  454. }
  455. .tableZ_box {
  456. border: 1px solid #e3e5e5;
  457. margin: 6px 0;
  458. &:last-child {
  459. border-bottom: none;
  460. }
  461. .row {
  462. width: 100%;
  463. display: flex;
  464. }
  465. .col {
  466. width: calc(100% / 5);
  467. display: flex;
  468. align-items: center;
  469. min-width: 200px;
  470. min-height: 32px;
  471. border-bottom: 1px solid #e3e5e5;
  472. border-right: 1px solid #e3e5e5;
  473. &:last-child {
  474. border-right: none;
  475. }
  476. .name {
  477. display: flex;
  478. align-items: center;
  479. padding: 4px;
  480. width: 80px;
  481. height: 100%;
  482. background-color: #d0e4d5;
  483. color: #000;
  484. }
  485. .content {
  486. padding: 4px 6px;
  487. color: #000;
  488. }
  489. }
  490. .pd6 {
  491. padding: 0 6px;
  492. }
  493. }
  494. </style>
  495. <style lang="scss" scoped>
  496. .seek-list {
  497. display: flex;
  498. justify-content: space-between;
  499. align-items: center;
  500. padding: 10px 10px;
  501. }
  502. .right_main_box {
  503. background-color: #fff;
  504. height: 100%;
  505. box-sizing: border-box;
  506. }
  507. .index_box {
  508. padding: 10px;
  509. padding-bottom: 0;
  510. width: 100%;
  511. box-sizing: border-box;
  512. min-width: 1280px !important;
  513. height: calc(100vh - 60px);
  514. // overflow-x: auto;
  515. /* 当内容超出宽度时,允许水平滚动 */
  516. white-space: nowrap;
  517. /* 防止内部文本换行,确保所有内容都在一行显示 */
  518. scrollbar-width: thin;
  519. /* 设置滚动条宽度(浏览器兼容性可能有所不同) */
  520. scrollbar-color: #40a9ff transparent;
  521. /* 设置滚动条颜色和轨道颜色(同样,浏览器兼容性) */
  522. }
  523. .main {
  524. width: 100%;
  525. min-width: 1280px;
  526. height: calc(100vh - 70px - 50px - 80px);
  527. display: flex;
  528. justify-content: space-between;
  529. }
  530. .left_main {
  531. width: 100%;
  532. height: 100%;
  533. display: flex;
  534. flex-direction: column;
  535. justify-content: space-around;
  536. min-width: 640px;
  537. .top {
  538. width: 100%;
  539. height: 100%;
  540. overflow: hidden;
  541. }
  542. // .bottom {
  543. // width: 100%;
  544. // min-height: calc((100vh - 70px - 50px - 80px - 20px) / 2);
  545. // overflow: hidden;
  546. // }
  547. }
  548. ::v-deep .el-tabs__item.is-active {
  549. background-color: #DFFADE;
  550. /* 蓝色背景 */
  551. color: #333;
  552. }
  553. ::v-deep .is-active {
  554. color: #DFFADE;
  555. }
  556. .right_main {
  557. min-width: 640px;
  558. padding-bottom: 12px;
  559. height: calc((100vh - 70px - 50px - 80px - 12px));
  560. background: #f0f3f3;
  561. }
  562. </style>