bottomOperate.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  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('outPicking', {})">委外领料</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. <!-- :disabled="outsourceForm.type == 2 ? false : true" -->
  47. <input class="uni-input content_num"
  48. v-model="outsourceForm.formedNumLast" type='number'></input>
  49. </u-form-item>
  50. <u-form-item label="委外物料:" borderBottom prop="" v-if="outsourceForm.type == 2">
  51. <zxz-uni-data-select :localdata="materialList" v-model="outsourceForm.material"
  52. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  53. </u-form-item>
  54. <u-form-item label="发货仓库:" borderBottom prop="" v-if="outsourceForm.type == 2">
  55. <zxz-uni-data-select :localdata="warehouseList" v-model="outsourceForm.warehouseId"
  56. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  57. </u-form-item>
  58. <u-form-item label="工艺路线:" borderBottom prop="" v-if="outsourceForm.type != 2">
  59. <zxz-uni-data-select :localdata="produceList" v-model="outsourceForm.produceRoutingId"
  60. dataValue='id' dataKey="name" filterable format='{name}'></zxz-uni-data-select>
  61. </u-form-item>
  62. <u-form-item label="委外到:" borderBottom prop="">
  63. <zxz-uni-data-select :localdata="newStepsList" v-model="outsourceForm.taskIds"
  64. dataValue='taskId' format='{taskTypeName}' dataKey="taskId" filterable
  65. :clear='true'></zxz-uni-data-select>
  66. </u-form-item>
  67. <u-form-item label="计划交期:" borderBottom prop="requireDeliveryTime">
  68. <picker mode="date" :value="outsourceForm.requireDeliveryTime" @change="onDateChange">
  69. <view class="uni-input">{{ outsourceForm.requireDeliveryTime || '选择日期' }}</view>
  70. </picker>
  71. </u-form-item>
  72. </u-form>
  73. </view>
  74. </template>
  75. <template v-slot:operate>
  76. <view class="operate_box rx-bc">
  77. <u-button size="small" class="u-reset-button" @click="outCancel">
  78. 取消
  79. </u-button>
  80. <u-button type="success" size="small" class="u-reset-button" @click="outsourceOk(0)">
  81. 提交
  82. </u-button>
  83. <u-button type="success" size="small" class="u-reset-button" @click="outsourceOk(1)">
  84. 提交并发布
  85. </u-button>
  86. </view>
  87. </template>
  88. </SearchPopup>
  89. </view>
  90. </template>
  91. <script>
  92. import {
  93. getTwoTreeByPid,
  94. checkOutsource,
  95. applyoutsourceSave,
  96. producerouting,
  97. getWarehouseList,
  98. updateStatusPause,
  99. updateStatusPauseRecover,
  100. updateStatusTerminate
  101. } from '@/api/pda/workOrder.js'
  102. import SearchPopup from './searchPopup.vue'
  103. export default {
  104. components: {
  105. SearchPopup
  106. },
  107. props: {
  108. state: String | Number,
  109. gdStatus: String | Number,
  110. taskObj: Object,
  111. controlReportMethod: String | Number,
  112. stepsList: {
  113. type: Array,
  114. default: () => []
  115. },
  116. },
  117. watch: {
  118. btns: {
  119. immediate: true,
  120. deep: true,
  121. handler(newVal) {
  122. this.btnsList = []
  123. this.btnsList = newVal
  124. }
  125. },
  126. state: {
  127. immediate: true,
  128. deep: true,
  129. handler(newVal) {
  130. this.btnState = newVal
  131. }
  132. },
  133. gdStatus: {
  134. immediate: true,
  135. deep: true,
  136. handler(newVal) {
  137. this.GDStatus = newVal
  138. }
  139. },
  140. controlReportMethod: {
  141. immediate: true,
  142. deep: true,
  143. handler(newVal) {
  144. this.btnControlReportMethod = newVal
  145. }
  146. },
  147. taskObj: {
  148. immediate: true,
  149. deep: true,
  150. handler(newVal) {
  151. console.log(newVal)
  152. this.newTaskObj = newVal
  153. }
  154. },
  155. stepsList: {
  156. immediate: true,
  157. deep: true,
  158. handler(newVal) {
  159. }
  160. }
  161. },
  162. data() {
  163. return {
  164. isOperate: false,
  165. btnsList: [],
  166. btnState: 1,
  167. GDStatus: null,
  168. btnControlReportMethod: null,
  169. btnList: {
  170. 1: [{
  171. name: '领料',
  172. type: 'picking'
  173. },
  174. {
  175. name: '投料',
  176. type: 'feeding'
  177. },
  178. {
  179. name: '更换周转车',
  180. type: 'turnover'
  181. },
  182. ],
  183. 2: [{
  184. name: '取样',
  185. type: 'sample'
  186. },
  187. {
  188. name: '报工',
  189. type: 'sampleJob'
  190. },
  191. ],
  192. 3: [{
  193. name: '更换周转车',
  194. type: 'qualityTurnover'
  195. },
  196. {
  197. name: '质检',
  198. type: 'inspection'
  199. },
  200. {
  201. name: '报工',
  202. type: 'inspectionJob'
  203. }
  204. ],
  205. 4: [{
  206. name: '领料',
  207. type: 'picking'
  208. },
  209. {
  210. name: '投料',
  211. type: 'feeding'
  212. },
  213. {
  214. name: '报工',
  215. type: 'jobBooking'
  216. },
  217. ],
  218. 5: [{
  219. name: '入库',
  220. type: 'warehousing'
  221. },
  222. ],
  223. 6: [{
  224. name: '报工',
  225. type: 'jobBooking'
  226. },
  227. ],
  228. },
  229. newTaskObj: {},
  230. outsourceShow: false,
  231. outsourceForm: {
  232. },
  233. produceList: [],
  234. warehouseList: [],
  235. typeList: [{
  236. id: 1,
  237. name: '采购委外'
  238. },
  239. {
  240. id: 2,
  241. name: '直接发货委外'
  242. },
  243. {
  244. id: 3,
  245. name: '无采购委外'
  246. },
  247. ],
  248. materialList: [{
  249. id: 1,
  250. name: '产品'
  251. },
  252. {
  253. id: 2,
  254. name: '半成品'
  255. },
  256. ],
  257. newStepsList: [],
  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. onDateChange(e) {
  357. this.$set(this.outsourceForm, 'requireDeliveryTime', e.detail.value)
  358. this.$forceUpdate()
  359. },
  360. // 工艺路线
  361. produceFn() {
  362. let param = {
  363. pageNum: 1,
  364. size: -1,
  365. routeType: 2
  366. }
  367. producerouting(param).then(res => {
  368. this.produceList = res.list
  369. })
  370. },
  371. // 仓库
  372. getWarehouseFn() {
  373. getWarehouseList().then(res => {
  374. this.warehouseList = res
  375. })
  376. },
  377. outsourceOk(isRelease) {
  378. if (!this.outsourceForm.name) {
  379. uni.showToast({
  380. title: '请输入委外名称',
  381. icon: 'none'
  382. })
  383. return false
  384. }
  385. if (!this.outsourceForm.type) {
  386. uni.showToast({
  387. title: '请选择委外类型',
  388. icon: 'none'
  389. })
  390. return false
  391. }
  392. if (this.outsourceForm.type == 2 && !this.outsourceForm.material) {
  393. uni.showToast({
  394. title: '请选择委外物料',
  395. icon: 'none'
  396. })
  397. return false
  398. }
  399. if ( this.outsourceForm.type != 2 && !this.outsourceForm.produceRoutingId) {
  400. uni.showToast({
  401. title: '请选择工艺路线',
  402. icon: 'none'
  403. })
  404. return false
  405. }
  406. // this.outsourceForm.requireDeliveryTime = '2025-03-18'
  407. if (!this.outsourceForm.requireDeliveryTime) {
  408. uni.showToast({
  409. title: '请选择委外完成时间',
  410. icon: 'none'
  411. })
  412. return false
  413. }
  414. let param = {
  415. ...this.outsourceForm,
  416. taskId: this.newTaskObj.currentTaskId,
  417. workOrderId: this.newTaskObj.workOrderId,
  418. isRelease: isRelease
  419. }
  420. applyoutsourceSave(param).then(res => {
  421. console.log(res)
  422. this.outCancel()
  423. })
  424. },
  425. }
  426. }
  427. </script>
  428. <style lang="scss" scoped>
  429. .bottom_box {
  430. background: #fff;
  431. }
  432. .nav_box {
  433. width: 750rpx;
  434. height: 40rpx;
  435. background: $theme-color;
  436. .open_icon {
  437. width: 48rpx;
  438. height: 48rpx;
  439. }
  440. .open_icon_reversal {
  441. transform: scaleY(-1);
  442. /* 垂直翻转 */
  443. }
  444. }
  445. .operate_list {
  446. margin: 0 32rpx;
  447. .list {
  448. border-radius: 8rpx;
  449. border: 1rpx solid $theme-color;
  450. background: #F0F8F2;
  451. height: 64rpx;
  452. padding: 0rpx 16rpx;
  453. margin-top: 16rpx;
  454. }
  455. .round {
  456. width: 32rpx;
  457. height: 32rpx;
  458. line-height: 32rpx;
  459. text-align: center;
  460. border-radius: 50%;
  461. background: $theme-color;
  462. font-size: 24rpx;
  463. font-style: normal;
  464. font-weight: 400;
  465. color: #fff;
  466. }
  467. .name {
  468. font-family: PingFang HK;
  469. font-size: 24rpx;
  470. font-style: normal;
  471. font-weight: 600;
  472. color: $theme-color;
  473. }
  474. .arrow_right {
  475. width: 32rpx;
  476. height: 32rpx;
  477. }
  478. }
  479. .btn_box {
  480. display: flex;
  481. padding: 16rpx 32rpx;
  482. align-items: flex-start;
  483. gap: 16rpx;
  484. align-self: stretch;
  485. .btn {
  486. width: 160rpx;
  487. height: 64rpx;
  488. line-height: 64rpx;
  489. background: $theme-color;
  490. text-align: center;
  491. border-radius: 8rpx;
  492. color: #fff;
  493. font-family: PingFang HK;
  494. font-size: 24rpx;
  495. font-style: normal;
  496. font-weight: 600;
  497. }
  498. }
  499. .operate_box {
  500. padding: 10rpx 20rpx;
  501. /deep/ .u-button {
  502. width: 180rpx;
  503. }
  504. }
  505. .popup_list {
  506. width: 78vw;
  507. min-height: 360rpx;
  508. padding: 0 32rpx;
  509. .title {
  510. color: #333;
  511. font-size: 28rpx;
  512. text-align: center;
  513. padding: 30rpx;
  514. }
  515. }
  516. .list_item_btn {
  517. width: 160rpx;
  518. height: 54rpx;
  519. line-height: 54rpx;
  520. background: $theme-color;
  521. text-align: center;
  522. border-radius: 8rpx;
  523. color: #fff;
  524. font-family: PingFang HK;
  525. font-size: 22rpx;
  526. font-style: normal;
  527. font-weight: 600;
  528. }
  529. .content_num {
  530. display: flex;
  531. align-items: center;
  532. padding: 0 4rpx;
  533. /deep/ .uni-input-input {
  534. border: 2rpx solid #F0F8F2;
  535. background: #F0F8F2;
  536. color: $theme-color;
  537. }
  538. }
  539. </style>