bottomOperate.vue 14 KB

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