index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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. if (this.List[0].turnover.length == 0) {
  194. uni.showToast({
  195. icon: "none",
  196. title: "请先添加周转车取样",
  197. });
  198. return false;
  199. }
  200. let _count = [];
  201. this.List[0].turnover &&
  202. this.List[0].turnover.forEach((f) => {
  203. if (
  204. f.extInfo &&
  205. f.extInfo.positionList &&
  206. f.extInfo.positionList.length > 0
  207. ) {
  208. console.log(f.extInfo.positionList, 'ooooooooooooooooo');
  209. let arr = f.extInfo.positionList.filter((o) => o.sampleNum >= 1)
  210. if (arr.length) {
  211. arr.map(f => {
  212. let obj ={
  213. quantity:f.sampleNum,
  214. code:f.code
  215. }
  216. _count.push(obj)
  217. })
  218. }
  219. console.log(arr, 'ooooooooooooooooo');
  220. // // if (Object.prototype.hasOwnProperty.call(o, "sampleNum") && o.sampleNum >= 1) {
  221. // // _count = _count + Number(o.sampleNum);
  222. // // }
  223. // });
  224. }
  225. });
  226. // if (_count < 1) {
  227. // uni.showToast({
  228. // icon: "none",
  229. // title: "请先取样",
  230. // });
  231. // return false;
  232. // }
  233. let param = {
  234. taskId: this.taskId,
  235. workOrderId: this.id,
  236. areaQuantity: _count
  237. }
  238. qualityQy(param).then(res => {
  239. this.$set(this.List[0], 'semiProductList', res)
  240. this.$forceUpdate()
  241. this.isShow = true;
  242. })
  243. },
  244. handQuality() {
  245. if (Object.prototype.hasOwnProperty.call(this.List[0], 'lastObj') && this.List[0].lastObj.formedNum >
  246. 0) { } else {
  247. uni.showToast({
  248. icon: "none",
  249. title: "暂无质检合格数",
  250. });
  251. return false
  252. }
  253. this.qualityShow = true;
  254. this.isZjs = true;
  255. },
  256. cancel() {
  257. this.qualityShow = false
  258. },
  259. qualityOk() {
  260. if (!this.qualityForm.num && this.qualityForm.num < 1) {
  261. uni.showToast({
  262. icon: "none",
  263. title: "请先输入质检取样数",
  264. });
  265. return false
  266. }
  267. let param = {
  268. taskId: this.taskId,
  269. workOrderId: this.id,
  270. quantity: this.qualityForm.num
  271. }
  272. qualityQy(param).then(res => {
  273. this.$set(this.List[0], 'semiProductList', res)
  274. this.qualityShow = false
  275. this.$forceUpdate()
  276. this.isShow = true;
  277. })
  278. },
  279. save() {
  280. if(!this.isShow){
  281. this.List[0].turnover &&
  282. this.List[0].turnover.forEach((f) => {
  283. if (
  284. f.extInfo &&
  285. f.extInfo.positionList &&
  286. f.extInfo.positionList.length > 0
  287. ) {
  288. let arr = f.extInfo.positionList.filter((o) => o.sampleNum >= 1)
  289. if (arr.length) {
  290. uni.showToast({
  291. icon: "none",
  292. title: "请先点击周转车质检",
  293. });
  294. }
  295. }
  296. });
  297. }
  298. // console.log(this.List);
  299. // // .turnover
  300. // return
  301. batchSave(this.List).then((res) => {
  302. uni.navigateBack();
  303. });
  304. },
  305. handAdd(id) {
  306. console.log(id);
  307. const storageKey = Date.now() + "";
  308. uni.setStorageSync(storageKey, this.List || []);
  309. uni.navigateTo({
  310. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.taskId}&classIds=[4,7]`,
  311. });
  312. },
  313. },
  314. };
  315. </script>
  316. <style lang="scss" scoped>
  317. .content-box {
  318. height: 100vh;
  319. overflow: hidden;
  320. display: flex;
  321. flex-direction: column;
  322. }
  323. .list_box {
  324. flex: 1;
  325. overflow: hidden;
  326. padding: 4rpx 0;
  327. .u-list {
  328. height: 100% !important;
  329. }
  330. .card_box {
  331. padding: 16rpx 24rpx;
  332. }
  333. }
  334. .bottom-wrapper {
  335. .btn_box {
  336. width: 750rpx;
  337. height: 88rpx;
  338. line-height: 88rpx;
  339. background: $theme-color;
  340. text-align: center;
  341. font-size: 36rpx;
  342. font-style: normal;
  343. font-weight: 400;
  344. color: #fff;
  345. }
  346. }
  347. .operate_box {
  348. padding: 10rpx 20rpx;
  349. /deep/ .u-button {
  350. width: 160rpx;
  351. }
  352. }
  353. .popup_list {
  354. width: 78vw;
  355. min-height: 120rpx;
  356. padding: 0 32rpx;
  357. }
  358. </style>