bottomOperate.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  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. console.log(this.newTaskObj)
  272. let param = {
  273. taskId: this.newTaskObj.currentTaskId,
  274. workOrderId: this.newTaskObj.workOrderId,
  275. }
  276. checkOutsource(param).then(res => {
  277. this.outsourceForm = {
  278. ...res,
  279. }
  280. this.outsourceForm.name = this.taskObj.currentTaskName + '委外'
  281. if (res.outsource) {
  282. this.getNewSteps()
  283. this.outsourceShow = true
  284. this.produceFn()
  285. this.getWarehouseFn()
  286. } else {
  287. uni.showToast({
  288. title: '此工序不能委外',
  289. icon: 'none'
  290. })
  291. }
  292. })
  293. },
  294. handPause() {
  295. if (this.GDStatus == 9) {
  296. uni.showModal({
  297. title: '提示',
  298. content: '确定该工单取消暂停?',
  299. success: async res => {
  300. if (res.confirm) {
  301. updateStatusPauseRecover([this.newTaskObj.workOrderId]).then(res => {
  302. this.$emit('refresh')
  303. })
  304. }
  305. }
  306. })
  307. } else {
  308. uni.showModal({
  309. title: '提示',
  310. content: '确定该工单暂停?',
  311. success: async res => {
  312. if (res.confirm) {
  313. updateStatusPause([this.newTaskObj.workOrderId]).then(res => {
  314. this.$emit('refresh')
  315. })
  316. }
  317. }
  318. })
  319. }
  320. },
  321. handTerminate() {
  322. uni.showModal({
  323. title: '提示',
  324. content: '确定该工单终止?',
  325. success: async res => {
  326. if (res.confirm) {
  327. updateStatusTerminate([this.newTaskObj.workOrderId]).then(res => {
  328. this.$emit('refresh')
  329. })
  330. }
  331. }
  332. })
  333. },
  334. outCancel() {
  335. this.outsourceShow = false
  336. },
  337. getNewSteps() {
  338. this.activeIndex = this.getIndexOfElementInArray(this.stepsList, this.newTaskObj.currentTaskId)
  339. this.newStepsList = []
  340. this.stepsList.forEach((f, i) => {
  341. if (f.taskId != '-1' && f.taskId != '-2' && i > this.activeIndex && (f.type == 1 || f.type == 4 )) {
  342. this.newStepsList.push(f)
  343. }
  344. })
  345. },
  346. getIndexOfElementInArray(array, target) {
  347. for (let i = 0; i < array.length; i++) {
  348. if (array[i].taskId === target) {
  349. return i; // 返回第一次出现target的索引位置
  350. }
  351. }
  352. return -1; // 未找到目标值时返回-1
  353. },
  354. changeOut() {
  355. if (this.endTaskId) {
  356. const index = this.newStepsList.findIndex(item => item.taskId === this.endTaskId) + 1;
  357. if (index !== -1) {
  358. // 使用slice截取目标元素之前的部分,并通过map提取id
  359. const previousIds = this.newStepsList.slice(0, index).map(item => item.taskId);
  360. this.outsourceForm.taskIds = previousIds.join(',')
  361. } else {
  362. this.outsourceForm.taskIds = ''
  363. }
  364. } else {
  365. this.outsourceForm.taskIds = ''
  366. }
  367. console.log(this.endTaskId)
  368. },
  369. onDateChange(e) {
  370. this.$set(this.outsourceForm, 'requireDeliveryTime', e.detail.value)
  371. this.$forceUpdate()
  372. },
  373. // 工艺路线
  374. produceFn() {
  375. let param = {
  376. pageNum: 1,
  377. size: -1,
  378. routeType: 2
  379. }
  380. producerouting(param).then(res => {
  381. this.produceList = res.list
  382. })
  383. },
  384. // 仓库
  385. getWarehouseFn() {
  386. getWarehouseList().then(res => {
  387. this.warehouseList = res
  388. })
  389. },
  390. outsourceOk(isRelease) {
  391. if (!this.outsourceForm.name) {
  392. uni.showToast({
  393. title: '请输入委外名称',
  394. icon: 'none'
  395. })
  396. return false
  397. }
  398. if (!this.outsourceForm.type) {
  399. uni.showToast({
  400. title: '请选择委外类型',
  401. icon: 'none'
  402. })
  403. return false
  404. }
  405. if (this.outsourceForm.type == 2 && !this.outsourceForm.material) {
  406. uni.showToast({
  407. title: '请选择委外物料',
  408. icon: 'none'
  409. })
  410. return false
  411. }
  412. if (this.clientEnvironmentId != 2 && !this.outsourceForm.produceRoutingId) {
  413. uni.showToast({
  414. title: '请选择工艺路线',
  415. icon: 'none'
  416. })
  417. return false
  418. }
  419. // this.outsourceForm.requireDeliveryTime = '2025-03-18'
  420. if (!this.outsourceForm.requireDeliveryTime) {
  421. uni.showToast({
  422. title: '请选择委外完成时间',
  423. icon: 'none'
  424. })
  425. return false
  426. }
  427. let param = {
  428. ...this.outsourceForm,
  429. taskId: this.newTaskObj.currentTaskId,
  430. workOrderId: this.newTaskObj.workOrderId,
  431. isRelease: isRelease
  432. }
  433. applyoutsourceSave(param).then(res => {
  434. console.log(res)
  435. this.outCancel()
  436. })
  437. },
  438. }
  439. }
  440. </script>
  441. <style lang="scss" scoped>
  442. .bottom_box {
  443. background: #fff;
  444. }
  445. .nav_box {
  446. width: 750rpx;
  447. height: 40rpx;
  448. background: $theme-color;
  449. .open_icon {
  450. width: 48rpx;
  451. height: 48rpx;
  452. }
  453. .open_icon_reversal {
  454. transform: scaleY(-1);
  455. /* 垂直翻转 */
  456. }
  457. }
  458. .operate_list {
  459. margin: 0 32rpx;
  460. .list {
  461. border-radius: 8rpx;
  462. border: 1rpx solid $theme-color;
  463. background: #F0F8F2;
  464. height: 64rpx;
  465. padding: 0rpx 16rpx;
  466. margin-top: 16rpx;
  467. }
  468. .round {
  469. width: 32rpx;
  470. height: 32rpx;
  471. line-height: 32rpx;
  472. text-align: center;
  473. border-radius: 50%;
  474. background: $theme-color;
  475. font-size: 24rpx;
  476. font-style: normal;
  477. font-weight: 400;
  478. color: #fff;
  479. }
  480. .name {
  481. font-family: PingFang HK;
  482. font-size: 24rpx;
  483. font-style: normal;
  484. font-weight: 600;
  485. color: $theme-color;
  486. }
  487. .arrow_right {
  488. width: 32rpx;
  489. height: 32rpx;
  490. }
  491. }
  492. .btn_box {
  493. display: flex;
  494. padding: 16rpx 32rpx;
  495. align-items: flex-start;
  496. gap: 16rpx;
  497. align-self: stretch;
  498. .btn {
  499. width: 160rpx;
  500. height: 64rpx;
  501. line-height: 64rpx;
  502. background: $theme-color;
  503. text-align: center;
  504. border-radius: 8rpx;
  505. color: #fff;
  506. font-family: PingFang HK;
  507. font-size: 24rpx;
  508. font-style: normal;
  509. font-weight: 600;
  510. }
  511. }
  512. .operate_box {
  513. padding: 10rpx 20rpx;
  514. /deep/ .u-button {
  515. width: 180rpx;
  516. }
  517. }
  518. .popup_list {
  519. width: 78vw;
  520. min-height: 360rpx;
  521. padding: 0 32rpx;
  522. .title {
  523. color: #333;
  524. font-size: 28rpx;
  525. text-align: center;
  526. padding: 30rpx;
  527. }
  528. }
  529. .list_item_btn {
  530. width: 160rpx;
  531. height: 54rpx;
  532. line-height: 54rpx;
  533. background: $theme-color;
  534. text-align: center;
  535. border-radius: 8rpx;
  536. color: #fff;
  537. font-family: PingFang HK;
  538. font-size: 22rpx;
  539. font-style: normal;
  540. font-weight: 600;
  541. }
  542. .content_num {
  543. display: flex;
  544. align-items: center;
  545. padding: 0 4rpx;
  546. /deep/ .uni-input-input {
  547. border: 2rpx solid #F0F8F2;
  548. background: #F0F8F2;
  549. color: $theme-color;
  550. }
  551. }
  552. </style>