index.vue 13 KB

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