bottomOperate.vue 13 KB

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