index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="content-box">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
  4. color="#000" @clickLeft="back">
  5. </uni-nav-bar>
  6. <view class="list_box">
  7. <u-list @scrolltolower="scrolltolower">
  8. <view class="card_box" v-for="(item, index) in List" :key="index">
  9. <workOrderBom :item="item" v-if="item" @handleScan="handleWordScan"></workOrderBom>
  10. <deviceBom v-if="item.equipmentList.length != 0" :workOrderId="item.workOrderId"
  11. :list="item.equipmentList" @scanIt="scanIt"></deviceBom>
  12. <!-- 周转车质检列表: -->
  13. <turnoverBom v-if="item.turnover.length != 0" :list="item.turnover" :wordItem="item" pattern="job">
  14. </turnoverBom>
  15. <!-- item.code -->
  16. <view class="operate_box rx-sc">
  17. <u-button size="small" class="u-reset-button" type="success"
  18. @click="handAdd(item.workOrderId)">手动添加</u-button>
  19. <u-button size="small" class="u-reset-button" type="success"
  20. @click="scanIt(item.workOrderId)">扫一扫</u-button>
  21. <u-button size="small" class="u-reset-button" type="success" style="width: 200rpx;"
  22. @click="handZZCQuality">周转车质检</u-button>
  23. <u-button size="small" class="u-reset-button" type="success" @click="handQuality">质检</u-button>
  24. </view>
  25. <diagramLast v-if="item && Object.prototype.hasOwnProperty.call(item, 'lastObj') &&
  26. item.workOrderType != 2" :item="item.lastObj"></diagramLast>
  27. <!-- 质检列表 -->
  28. <inspectionBom
  29. v-if='Object.prototype.hasOwnProperty.call(item, "semiProductList") && item.semiProductList'
  30. :semiProductList='item.semiProductList'></inspectionBom>
  31. </view>
  32. </u-list>
  33. </view>
  34. <SearchPopup mode="center" v-if="qualityShow">
  35. <template v-slot:list>
  36. <view class="popup_list">
  37. <u-form labelPosition="left" :model="qualityForm" labelWidth="180" labelAlign="left" class="">
  38. <u-form-item label="质检取样数:" borderBottom prop="num">
  39. <input class="uni-input" v-model="qualityForm.num" placeholder="请输入质检取样数"></input>
  40. </u-form-item>
  41. </u-form>
  42. </view>
  43. </template>
  44. <template v-slot:operate>
  45. <view class="operate_box rx-bc">
  46. <u-button size="small" class="u-reset-button" @click="cancel">
  47. 取消
  48. </u-button>
  49. <u-button type="success" size="small" class="u-reset-button" @click="qualityOk">
  50. 确定
  51. </u-button>
  52. </view>
  53. </template>
  54. </SearchPopup>
  55. <view class="bottom-wrapper">
  56. <view class="btn_box" @click="save">确认</view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. workorderList,
  63. scanLedger,
  64. qualityQy
  65. } from "@/api/pda/workOrder.js";
  66. import {
  67. batchSave
  68. } from "@/api/pda/feeding.js";
  69. import workOrderBom from "../../feeding/components/workOrderBom.vue";
  70. import inspectionBom from "../components/inspectionBom.vue";
  71. import deviceBom from "../../feeding/components/deviceBom.vue";
  72. import diagramLast from "../components/diagramLast.vue";
  73. import turnoverBom from "../../sample/components/turnoverBom.vue";
  74. import SearchPopup from '../../components/searchPopup.vue'
  75. export default {
  76. components: {
  77. workOrderBom,
  78. inspectionBom,
  79. deviceBom,
  80. diagramLast,
  81. turnoverBom,
  82. SearchPopup
  83. },
  84. data() {
  85. return {
  86. title: null,
  87. id: null,
  88. taskId: null,
  89. isShow:false,
  90. isZjs:false,
  91. List: [],
  92. qualityShow: false,
  93. qualityForm: {
  94. num: null,
  95. }
  96. };
  97. },
  98. onLoad(options) {
  99. this.title = options.taskName || '质检'
  100. this.id = options.workOrderId;
  101. this.taskId = options.taskId;
  102. this.getList();
  103. },
  104. onShow() {
  105. uni.$off("setSelectList");
  106. uni.$on("setSelectList", (selectList, id) => {
  107. this.List.forEach((m) => {
  108. if (m.workOrderId == id) {
  109. let equipmentList = []; // 生产设备
  110. let turnover = [];
  111. selectList.forEach((f) => {
  112. if (f.rootCategoryLevelId == 4) {
  113. equipmentList = equipmentList.concat(f);
  114. }
  115. if (f.rootCategoryLevelId == 7) {
  116. turnover = turnover.concat(f);
  117. }
  118. });
  119. this.$set(m, "equipmentList", equipmentList);
  120. this.$set(m, "turnover", turnover);
  121. }
  122. });
  123. });
  124. },
  125. methods: {
  126. getList() {
  127. workorderList({
  128. ids: [this.id],
  129. taskId: this.taskId,
  130. }).then((res) => {
  131. this.List = res.map((m) => {
  132. m.workOrderId = m.id;
  133. m.equipmentList = []; // 设备
  134. m.turnover = []; // 周转车
  135. m.lastObj = {
  136. formedNum: m.formedNumLast,
  137. taskNameLast: m.taskNameLast,
  138. unit: m.unit,
  139. };
  140. m.feedType = 3;
  141. delete m.id;
  142. if (this.taskId) {
  143. m.taskId = this.taskId;
  144. }
  145. return {
  146. ...m,
  147. };
  148. });
  149. });
  150. },
  151. scrolltolower() { },
  152. handleWordScan() {
  153. uni.showToast({
  154. icon: "none",
  155. title: "不支持换工单",
  156. });
  157. },
  158. scanIt(id) {
  159. uni.scanCode({
  160. success: (res) => {
  161. this.scanItData(res.result, id);
  162. },
  163. });
  164. },
  165. scanItData(result, id) {
  166. scanLedger(result).then((res) => {
  167. let _arr = [];
  168. if (res.length == 1 && res[0].rootCategoryLevelId == 4) {
  169. // 设备
  170. _arr = this.List;
  171. _arr.forEach((e, index) => {
  172. if (e.workOrderId == id) {
  173. _arr[index].equipmentList = res;
  174. }
  175. });
  176. this.List = _arr;
  177. this.$forceUpdate();
  178. }
  179. if (res.length == 1 && res[0].rootCategoryLevelId == 7) {
  180. // 周转车
  181. _arr = this.List;
  182. _arr.forEach((e, index) => {
  183. if (e.workOrderId == id) {
  184. _arr[index].turnover = res;
  185. }
  186. });
  187. this.List = _arr;
  188. this.$forceUpdate();
  189. }
  190. });
  191. },
  192. handZZCQuality() {
  193. console.log(this.List,'this.List');
  194. if (this.List[0].turnover.length == 0) {
  195. uni.showToast({
  196. icon: "none",
  197. title: "请先添加周转车取样",
  198. });
  199. return false;
  200. }
  201. let _count = [];
  202. this.List[0].turnover &&
  203. this.List[0].turnover.forEach((f) => {
  204. if (
  205. f.extInfo &&
  206. f.extInfo.positionList &&
  207. f.extInfo.positionList.length > 0
  208. ) {
  209. console.log(f.extInfo.positionList, 'ooooooooooooooooo');
  210. let arr = f.extInfo.positionList.filter((o) => o.sampleNum >= 1)
  211. if (arr.length) {
  212. arr.map(d => {
  213. let obj ={
  214. quantity:d.sampleNum,
  215. code:d.code,
  216. vehicleId:f.id,
  217. vehicleName:f.name,
  218. vehicleCode:f.code,
  219. }
  220. _count.push(obj)
  221. })
  222. }
  223. console.log(arr, 'ooooooooooooooooo');
  224. // // if (Object.prototype.hasOwnProperty.call(o, "sampleNum") && o.sampleNum >= 1) {
  225. // // _count = _count + Number(o.sampleNum);
  226. // // }
  227. // });
  228. }
  229. });
  230. // if (_count < 1) {
  231. // uni.showToast({
  232. // icon: "none",
  233. // title: "请先取样",
  234. // });
  235. // return false;
  236. // }
  237. let param = {
  238. taskId: this.taskId,
  239. workOrderId: this.id,
  240. areaQuantity: _count
  241. }
  242. qualityQy(param).then(res => {
  243. this.$set(this.List[0], 'semiProductList', res)
  244. this.$forceUpdate()
  245. this.isShow = true;
  246. })
  247. },
  248. handQuality() {
  249. if (Object.prototype.hasOwnProperty.call(this.List[0], 'lastObj') && this.List[0].lastObj.formedNum >
  250. 0) { } else {
  251. uni.showToast({
  252. icon: "none",
  253. title: "暂无质检合格数",
  254. });
  255. return false
  256. }
  257. this.qualityShow = true;
  258. this.isZjs = true;
  259. },
  260. cancel() {
  261. this.qualityShow = false
  262. },
  263. qualityOk() {
  264. if (!this.qualityForm.num && this.qualityForm.num < 1) {
  265. uni.showToast({
  266. icon: "none",
  267. title: "请先输入质检取样数",
  268. });
  269. return false
  270. }
  271. let param = {
  272. taskId: this.taskId,
  273. workOrderId: this.id,
  274. quantity: this.qualityForm.num
  275. }
  276. qualityQy(param).then(res => {
  277. this.$set(this.List[0], 'semiProductList', res)
  278. this.qualityShow = false
  279. this.$forceUpdate()
  280. this.isShow = true;
  281. })
  282. },
  283. save() {
  284. if(!this.isShow){
  285. this.List[0].turnover &&
  286. this.List[0].turnover.forEach((f) => {
  287. if (
  288. f.extInfo &&
  289. f.extInfo.positionList &&
  290. f.extInfo.positionList.length > 0
  291. ) {
  292. let arr = f.extInfo.positionList.filter((o) => o.sampleNum >= 1)
  293. if (arr.length) {
  294. uni.showToast({
  295. icon: "none",
  296. title: "请先点击周转车质检",
  297. });
  298. }
  299. }
  300. });
  301. }
  302. // console.log(this.List);
  303. // // .turnover
  304. // return
  305. batchSave(this.List).then((res) => {
  306. uni.navigateBack();
  307. });
  308. },
  309. handAdd(id) {
  310. console.log(id);
  311. const storageKey = Date.now() + "";
  312. uni.setStorageSync(storageKey, this.List || []);
  313. uni.navigateTo({
  314. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.taskId}&classIds=[4,7]`,
  315. });
  316. },
  317. },
  318. };
  319. </script>
  320. <style lang="scss" scoped>
  321. .content-box {
  322. height: 100vh;
  323. overflow: hidden;
  324. display: flex;
  325. flex-direction: column;
  326. }
  327. .list_box {
  328. flex: 1;
  329. overflow: hidden;
  330. padding: 4rpx 0;
  331. .u-list {
  332. height: 100% !important;
  333. }
  334. .card_box {
  335. padding: 16rpx 24rpx;
  336. }
  337. }
  338. .bottom-wrapper {
  339. .btn_box {
  340. width: 750rpx;
  341. height: 88rpx;
  342. line-height: 88rpx;
  343. background: $theme-color;
  344. text-align: center;
  345. font-size: 36rpx;
  346. font-style: normal;
  347. font-weight: 400;
  348. color: #fff;
  349. }
  350. }
  351. .operate_box {
  352. padding: 10rpx 20rpx;
  353. /deep/ .u-button {
  354. width: 160rpx;
  355. }
  356. }
  357. .popup_list {
  358. width: 78vw;
  359. min-height: 120rpx;
  360. padding: 0 32rpx;
  361. }
  362. </style>