bottomOperate.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. <template>
  2. <view class="bottom_box">
  3. <view class="nav_box rx-cc" @click="open">
  4. <image class="open_icon" :class="{open_icon_reversal : isOperate}" src="~@/static/pda/open.svg"></image>
  5. </view>
  6. <view class="operate_list" v-show="isOperate">
  7. <view v-for="(item, index) in btnList[btnState]" :key="index" class="list rx-bc"
  8. @click="operate(item.type, item)">
  9. <view class="round">{{index + 1}}</view>
  10. <view class="name">{{item.name}}</view>
  11. <image class="arrow_right" src="~@/static/pda/arrow_right.svg"></image>
  12. </view>
  13. <view v-if='btnControlReportMethod == 2' class="list rx-bc">
  14. <view class="round">{{btnList[btnState].length + 1}}</view>
  15. <view class="name" @click="operate('skip', {})" skip>跳过(不报工)</view>
  16. <image class="arrow_right" src="~@/static/pda/arrow_right.svg"></image>
  17. </view>
  18. <view class="list rx-bc" v-if="btnState == 1">
  19. <view class="list_item_btn" @click="operate('jobBooking', {})">报工</view>
  20. <view class="list_item_btn" @click="operate('',item)">批量报工</view>
  21. </view>
  22. <view class="list rx-bc" v-if="newTaskObj.existOutsource == 1">
  23. <view class="list_item_btn" @click="operate('jobBooking', {})">委外领料</view>
  24. <view class="list_item_btn" @click="operate('jobBooking', {})">委外报工</view>
  25. </view>
  26. </view>
  27. <view class="btn_box">
  28. <view class="btn" @click="handPause()">{{ GDStatus == 9 ? '取消暂停' : '暂停' }}</view>
  29. <view class="btn" @click="handTerminate()">终止</view>
  30. <view class="btn">转派</view>
  31. <view class="btn" @click="handOutsource()">委外</view>
  32. </view>
  33. <SearchPopup mode="center" v-if="outsourceShow">
  34. <template v-slot:list>
  35. <view class="popup_list">
  36. <view class="title">【{{taskObj.currentTaskName}}】是否委外</view>
  37. <u-form labelPosition="left" :model="outsourceForm" labelWidth="180" labelAlign="left" class="">
  38. <u-form-item label="委外名称:" borderBottom prop="num">
  39. <input class="uni-input" v-model="outsourceForm.name" placeholder="请输入委外名称"></input>
  40. </u-form-item>
  41. <u-form-item label="委外类型:" borderBottom prop="">
  42. <zxz-uni-data-select :localdata="typeList" v-model="outsourceForm.type" dataValue='id'
  43. dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  44. </u-form-item>
  45. <u-form-item label="委外数量:" borderBottom prop="num">
  46. <input class="uni-input content_num" :disabled="outsourceForm.type == 2 ? false : true"
  47. v-model="outsourceForm.formedNumLast" type='number'></input>
  48. </u-form-item>
  49. <u-form-item label="委外物料:" borderBottom prop="" v-if="outsourceForm.type == 2">
  50. <zxz-uni-data-select :localdata="materialList" v-model="outsourceForm.material"
  51. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  52. </u-form-item>
  53. <u-form-item label="发货仓库:" borderBottom prop="" v-if="outsourceForm.type == 2">
  54. <zxz-uni-data-select :localdata="warehouseList" v-model="outsourceForm.warehouseId"
  55. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  56. </u-form-item>
  57. <u-form-item label="工艺路线:" borderBottom prop="">
  58. <zxz-uni-data-select :localdata="produceList" v-model="outsourceForm.produceRoutingId"
  59. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  60. </u-form-item>
  61. <u-form-item label="委外到:" borderBottom prop="">
  62. <zxz-uni-data-select :localdata="newStepsList" v-model="endTaskId" @change="changeOut"
  63. dataValue='taskId' format='{taskTypeName}' dataKey="taskId" filterable
  64. :clear='true'></zxz-uni-data-select>
  65. </u-form-item>
  66. <u-form-item label="完成时间:" borderBottom prop="requireDeliveryTime">
  67. <picker mode="date" :value="outsourceForm.requireDeliveryTime" @change="onDateChange">
  68. <view class="uni-input">{{ outsourceForm.requireDeliveryTime || '选择日期' }}</view>
  69. </picker>
  70. </u-form-item>
  71. </u-form>
  72. </view>
  73. </template>
  74. <template v-slot:operate>
  75. <view class="operate_box rx-bc">
  76. <u-button size="small" class="u-reset-button" @click="outCancel">
  77. 取消
  78. </u-button>
  79. <u-button type="success" size="small" class="u-reset-button" @click="outsourceOk(0)">
  80. 提交
  81. </u-button>
  82. <u-button type="success" size="small" class="u-reset-button" @click="outsourceOk(1)">
  83. 提交并发布
  84. </u-button>
  85. </view>
  86. </template>
  87. </SearchPopup>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. getTwoTreeByPid,
  93. checkOutsource,
  94. applyoutsourceSave,
  95. producerouting,
  96. getWarehouseList,
  97. updateStatusPause,
  98. updateStatusPauseRecover,
  99. updateStatusTerminate
  100. } from '@/api/pda/workOrder.js'
  101. import SearchPopup from './searchPopup.vue'
  102. export default {
  103. components: {
  104. SearchPopup
  105. },
  106. props: {
  107. state: String | Number,
  108. gdStatus: String | Number,
  109. taskObj: Object,
  110. controlReportMethod: String | Number,
  111. stepsList: {
  112. type: Array,
  113. default: () => []
  114. },
  115. },
  116. watch: {
  117. btns: {
  118. immediate: true,
  119. deep: true,
  120. handler(newVal) {
  121. this.btnsList = []
  122. this.btnsList = newVal
  123. }
  124. },
  125. state: {
  126. immediate: true,
  127. deep: true,
  128. handler(newVal) {
  129. this.btnState = newVal
  130. }
  131. },
  132. gdStatus: {
  133. immediate: true,
  134. deep: true,
  135. handler(newVal) {
  136. this.GDStatus = newVal
  137. }
  138. },
  139. controlReportMethod: {
  140. immediate: true,
  141. deep: true,
  142. handler(newVal) {
  143. this.btnControlReportMethod = newVal
  144. }
  145. },
  146. taskObj: {
  147. immediate: true,
  148. deep: true,
  149. handler(newVal) {
  150. console.log(newVal)
  151. this.newTaskObj = newVal
  152. }
  153. },
  154. stepsList: {
  155. immediate: true,
  156. deep: true,
  157. handler(newVal) {
  158. }
  159. }
  160. },
  161. data() {
  162. return {
  163. isOperate: false,
  164. btnsList: [],
  165. btnState: 1,
  166. GDStatus: null,
  167. btnControlReportMethod: null,
  168. btnList: {
  169. 1: [{
  170. name: '领料',
  171. type: 'picking'
  172. },
  173. {
  174. name: '投料',
  175. type: 'feeding'
  176. },
  177. {
  178. name: '更换周转车',
  179. type: 'turnover'
  180. },
  181. ],
  182. 2: [{
  183. name: '取样',
  184. type: 'sample'
  185. },
  186. {
  187. name: '报工',
  188. type: 'sampleJob'
  189. },
  190. ],
  191. 3: [{
  192. name: '更换周转车',
  193. type: 'qualityTurnover'
  194. },
  195. {
  196. name: '质检',
  197. type: 'inspection'
  198. },
  199. {
  200. name: '报工',
  201. type: 'inspectionJob'
  202. }
  203. ],
  204. 4: [{
  205. name: '领料',
  206. type: 'picking'
  207. },
  208. {
  209. name: '投料',
  210. type: 'feeding'
  211. },
  212. {
  213. name: '报工',
  214. type: 'jobBooking'
  215. },
  216. ],
  217. 5: [{
  218. name: '入库',
  219. type: 'warehousing'
  220. },
  221. ],
  222. 6: [{
  223. name: '报工',
  224. type: 'jobBooking'
  225. },
  226. ],
  227. },
  228. newTaskObj: {},
  229. outsourceShow: false,
  230. outsourceForm: {
  231. },
  232. produceList: [],
  233. warehouseList: [],
  234. typeList: [{
  235. id: 1,
  236. name: '采购委外'
  237. },
  238. {
  239. id: 2,
  240. name: '直接发货委外'
  241. },
  242. {
  243. id: 3,
  244. name: '无采购委外'
  245. },
  246. ],
  247. materialList: [{
  248. id: 1,
  249. name: '产品'
  250. },
  251. {
  252. id: 2,
  253. name: '半成品'
  254. },
  255. ],
  256. newStepsList: [],
  257. endTaskId: null,
  258. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
  259. .clientEnvironmentId, // *1 主环境-601环境 2 soll-索尔环境 3 tg-碳谷环境
  260. }
  261. },
  262. created() {
  263. },
  264. methods: {
  265. open() {
  266. this.isOperate = !this.isOperate
  267. },
  268. operate(type, item) {
  269. this.$emit('operate', type, item)
  270. },
  271. handOutsource() {
  272. console.log(this.newTaskObj)
  273. let param = {
  274. taskId: this.newTaskObj.currentTaskId,
  275. workOrderId: this.newTaskObj.workOrderId,
  276. }
  277. checkOutsource(param).then(res => {
  278. this.outsourceForm = {
  279. ...res,
  280. }
  281. this.outsourceForm.name = this.taskObj.currentTaskName + '委外'
  282. if (res.outsource) {
  283. this.getNewSteps()
  284. this.outsourceShow = true
  285. this.produceFn()
  286. this.getWarehouseFn()
  287. } else {
  288. uni.showToast({
  289. title: '此工序不能委外',
  290. icon: 'none'
  291. })
  292. }
  293. })
  294. },
  295. handPause() {
  296. if (this.GDStatus == 9) {
  297. uni.showModal({
  298. title: '提示',
  299. content: '确定该工单取消暂停?',
  300. success: async res => {
  301. if (res.confirm) {
  302. updateStatusPauseRecover([this.newTaskObj.workOrderId]).then(res => {
  303. this.$emit('refresh')
  304. })
  305. }
  306. }
  307. })
  308. } else {
  309. uni.showModal({
  310. title: '提示',
  311. content: '确定该工单暂停?',
  312. success: async res => {
  313. if (res.confirm) {
  314. updateStatusPause([this.newTaskObj.workOrderId]).then(res => {
  315. this.$emit('refresh')
  316. })
  317. }
  318. }
  319. })
  320. }
  321. },
  322. handTerminate() {
  323. uni.showModal({
  324. title: '提示',
  325. content: '确定该工单终止?',
  326. success: async res => {
  327. if (res.confirm) {
  328. updateStatusTerminate([this.newTaskObj.workOrderId]).then(res => {
  329. this.$emit('refresh')
  330. })
  331. }
  332. }
  333. })
  334. },
  335. outCancel() {
  336. this.outsourceShow = false
  337. },
  338. getNewSteps() {
  339. this.activeIndex = this.getIndexOfElementInArray(this.stepsList, this.newTaskObj.currentTaskId)
  340. this.newStepsList = []
  341. this.stepsList.forEach((f, i) => {
  342. if (f.taskId != '-1' && f.taskId != '-2' && i > this.activeIndex && (f.type == 1 || f.type ==
  343. 4)) {
  344. this.newStepsList.push(f)
  345. }
  346. })
  347. },
  348. getIndexOfElementInArray(array, target) {
  349. for (let i = 0; i < array.length; i++) {
  350. if (array[i].taskId === target) {
  351. return i; // 返回第一次出现target的索引位置
  352. }
  353. }
  354. return -1; // 未找到目标值时返回-1
  355. },
  356. changeOut() {
  357. if (this.endTaskId) {
  358. const index = this.newStepsList.findIndex(item => item.taskId === this.endTaskId) + 1;
  359. if (index !== -1) {
  360. // 使用slice截取目标元素之前的部分,并通过map提取id
  361. const previousIds = this.newStepsList.slice(0, index).map(item => item.taskId);
  362. this.outsourceForm.taskIds = previousIds.join(',')
  363. } else {
  364. this.outsourceForm.taskIds = ''
  365. }
  366. } else {
  367. this.outsourceForm.taskIds = ''
  368. }
  369. console.log(this.endTaskId)
  370. },
  371. onDateChange(e) {
  372. this.$set(this.outsourceForm, 'requireDeliveryTime', e.detail.value)
  373. this.$forceUpdate()
  374. },
  375. // 工艺路线
  376. produceFn() {
  377. let param = {
  378. pageNum: 1,
  379. size: -1,
  380. routeType: 2
  381. }
  382. producerouting(param).then(res => {
  383. this.produceList = res.list
  384. })
  385. },
  386. // 仓库
  387. getWarehouseFn() {
  388. getWarehouseList().then(res => {
  389. this.warehouseList = res
  390. })
  391. },
  392. outsourceOk(isRelease) {
  393. if (!this.outsourceForm.name) {
  394. uni.showToast({
  395. title: '请输入委外名称',
  396. icon: 'none'
  397. })
  398. return false
  399. }
  400. if (!this.outsourceForm.type) {
  401. uni.showToast({
  402. title: '请选择委外类型',
  403. icon: 'none'
  404. })
  405. return false
  406. }
  407. if (this.outsourceForm.type == 2 && !this.outsourceForm.material) {
  408. uni.showToast({
  409. title: '请选择委外物料',
  410. icon: 'none'
  411. })
  412. return false
  413. }
  414. if (this.clientEnvironmentId != 2 && !this.outsourceForm.produceRoutingId) {
  415. uni.showToast({
  416. title: '请选择工艺路线',
  417. icon: 'none'
  418. })
  419. return false
  420. }
  421. // this.outsourceForm.requireDeliveryTime = '2025-03-18'
  422. if (!this.outsourceForm.requireDeliveryTime) {
  423. uni.showToast({
  424. title: '请选择委外完成时间',
  425. icon: 'none'
  426. })
  427. return false
  428. }
  429. let param = {
  430. ...this.outsourceForm,
  431. taskId: this.newTaskObj.currentTaskId,
  432. workOrderId: this.newTaskObj.workOrderId,
  433. isRelease: isRelease
  434. }
  435. applyoutsourceSave(param).then(res => {
  436. console.log(res)
  437. this.outCancel()
  438. })
  439. },
  440. }
  441. }
  442. </script>
  443. <style lang="scss" scoped>
  444. .bottom_box {
  445. background: #fff;
  446. }
  447. .nav_box {
  448. width: 750rpx;
  449. height: 40rpx;
  450. background: $theme-color;
  451. .open_icon {
  452. width: 48rpx;
  453. height: 48rpx;
  454. }
  455. .open_icon_reversal {
  456. transform: scaleY(-1);
  457. /* 垂直翻转 */
  458. }
  459. }
  460. .operate_list {
  461. margin: 0 32rpx;
  462. .list {
  463. border-radius: 8rpx;
  464. border: 1rpx solid $theme-color;
  465. background: #F0F8F2;
  466. height: 64rpx;
  467. padding: 0rpx 16rpx;
  468. margin-top: 16rpx;
  469. }
  470. .round {
  471. width: 32rpx;
  472. height: 32rpx;
  473. line-height: 32rpx;
  474. text-align: center;
  475. border-radius: 50%;
  476. background: $theme-color;
  477. font-size: 24rpx;
  478. font-style: normal;
  479. font-weight: 400;
  480. color: #fff;
  481. }
  482. .name {
  483. font-family: PingFang HK;
  484. font-size: 24rpx;
  485. font-style: normal;
  486. font-weight: 600;
  487. color: $theme-color;
  488. }
  489. .arrow_right {
  490. width: 32rpx;
  491. height: 32rpx;
  492. }
  493. }
  494. .btn_box {
  495. display: flex;
  496. padding: 16rpx 32rpx;
  497. align-items: flex-start;
  498. gap: 16rpx;
  499. align-self: stretch;
  500. .btn {
  501. width: 160rpx;
  502. height: 64rpx;
  503. line-height: 64rpx;
  504. background: $theme-color;
  505. text-align: center;
  506. border-radius: 8rpx;
  507. color: #fff;
  508. font-family: PingFang HK;
  509. font-size: 24rpx;
  510. font-style: normal;
  511. font-weight: 600;
  512. }
  513. }
  514. .operate_box {
  515. padding: 10rpx 20rpx;
  516. /deep/ .u-button {
  517. width: 180rpx;
  518. }
  519. }
  520. .popup_list {
  521. width: 78vw;
  522. min-height: 360rpx;
  523. padding: 0 32rpx;
  524. .title {
  525. color: #333;
  526. font-size: 28rpx;
  527. text-align: center;
  528. padding: 30rpx;
  529. }
  530. }
  531. .list_item_btn {
  532. width: 160rpx;
  533. height: 54rpx;
  534. line-height: 54rpx;
  535. background: $theme-color;
  536. text-align: center;
  537. border-radius: 8rpx;
  538. color: #fff;
  539. font-family: PingFang HK;
  540. font-size: 22rpx;
  541. font-style: normal;
  542. font-weight: 600;
  543. }
  544. .content_num {
  545. display: flex;
  546. align-items: center;
  547. padding: 0 4rpx;
  548. /deep/ .uni-input-input {
  549. border: 2rpx solid #F0F8F2;
  550. background: #F0F8F2;
  551. color: $theme-color;
  552. }
  553. }
  554. </style>