bottomOperate.vue 13 KB

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