index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. <turnoverBom v-if="item.turnover.length != 0" :list="item.turnover" :wordItem="item" pattern="job">
  13. </turnoverBom>
  14. <view class="operate_box rx-sc">
  15. <u-button size="small" class="u-reset-button" type="success"
  16. @click="handAdd(item.workOrderId)">手动添加</u-button>
  17. <u-button size="small" class="u-reset-button" type="success"
  18. @click="scanIt(item.workOrderId)">扫一扫</u-button>
  19. <u-button size="small" class="u-reset-button" type="success" @click="handQuality">质检</u-button>
  20. </view>
  21. <diagramLast v-if="item && Object.prototype.hasOwnProperty.call(item, 'lastObj') &&
  22. item.workOrderType !=2" :item="item.lastObj"></diagramLast>
  23. <inspectionBom
  24. v-if='Object.prototype.hasOwnProperty.call(item, "semiProductList") && item.semiProductList'
  25. :semiProductList='item.semiProductList'></inspectionBom>
  26. </view>
  27. </u-list>
  28. </view>
  29. <view class="bottom-wrapper">
  30. <view class="btn_box" @click="save">确认</view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. workorderList,
  37. scanLedger,
  38. qualityQy
  39. } from "@/api/pda/workOrder.js";
  40. import {
  41. batchSave
  42. } from "@/api/pda/feeding.js";
  43. import workOrderBom from "../../feeding/components/workOrderBom.vue";
  44. import inspectionBom from "../components/inspectionBom.vue";
  45. import deviceBom from "../../feeding/components/deviceBom.vue";
  46. import diagramLast from "../components/diagramLast.vue";
  47. import turnoverBom from "../../sample/components/turnoverBom.vue";
  48. export default {
  49. components: {
  50. workOrderBom,
  51. inspectionBom,
  52. deviceBom,
  53. diagramLast,
  54. turnoverBom,
  55. },
  56. data() {
  57. return {
  58. title: null,
  59. id: null,
  60. taskId: null,
  61. List: [],
  62. };
  63. },
  64. onLoad(options) {
  65. this.title = options.taskName || '质检'
  66. this.id = options.workOrderId;
  67. this.taskId = options.taskId;
  68. this.getList();
  69. },
  70. onShow() {
  71. uni.$off("setSelectList");
  72. uni.$on("setSelectList", (selectList, id) => {
  73. this.List.forEach((m) => {
  74. if (m.workOrderId == id) {
  75. let equipmentList = []; // 生产设备
  76. let turnover = [];
  77. selectList.forEach((f) => {
  78. if (f.rootCategoryLevelId == 4) {
  79. equipmentList = equipmentList.concat(f);
  80. }
  81. if (f.rootCategoryLevelId == 7) {
  82. turnover = turnover.concat(f);
  83. }
  84. });
  85. this.$set(m, "equipmentList", equipmentList);
  86. this.$set(m, "turnover", turnover);
  87. }
  88. });
  89. });
  90. },
  91. methods: {
  92. getList() {
  93. workorderList({
  94. ids: [this.id],
  95. taskId: this.taskId,
  96. }).then((res) => {
  97. this.List = res.map((m) => {
  98. m.workOrderId = m.id;
  99. m.equipmentList = []; // 设备
  100. m.turnover = []; // 周转车
  101. m.lastObj = {
  102. formedNum: m.formedNumLast,
  103. taskNameLast: m.taskNameLast,
  104. unit: m.unit,
  105. };
  106. m.feedType = 3;
  107. delete m.id;
  108. if (this.taskId) {
  109. m.taskId = this.taskId;
  110. }
  111. return {
  112. ...m,
  113. };
  114. });
  115. });
  116. },
  117. scrolltolower() {},
  118. handleWordScan() {
  119. uni.showToast({
  120. icon: "none",
  121. title: "不支持换工单",
  122. });
  123. },
  124. scanIt(id) {
  125. uni.scanCode({
  126. success: (res) => {
  127. this.scanItData(res.result, id);
  128. },
  129. });
  130. },
  131. scanItData(result, id) {
  132. scanLedger(result).then((res) => {
  133. let _arr = [];
  134. if (res.length == 1 && res[0].rootCategoryLevelId == 4) {
  135. // 设备
  136. _arr = this.List;
  137. _arr.forEach((e, index) => {
  138. if (e.workOrderId == id) {
  139. _arr[index].equipmentList = res;
  140. }
  141. });
  142. this.List = _arr;
  143. this.$forceUpdate();
  144. }
  145. if (res.length == 1 && res[0].rootCategoryLevelId == 7) {
  146. // 周转车
  147. _arr = this.List;
  148. _arr.forEach((e, index) => {
  149. if (e.workOrderId == id) {
  150. _arr[index].turnover = res;
  151. }
  152. });
  153. this.List = _arr;
  154. this.$forceUpdate();
  155. }
  156. });
  157. },
  158. handQuality() {
  159. console.log(this.List[0]);
  160. if (this.List[0].turnover.length == 0) {
  161. uni.showToast({
  162. icon: "none",
  163. title: "请先添加周转车取样",
  164. });
  165. return false;
  166. }
  167. let _count = 0;
  168. this.List[0].turnover &&
  169. this.List[0].turnover.forEach((f) => {
  170. if (
  171. f.extInfo &&
  172. f.extInfo.positionList &&
  173. f.extInfo.positionList.length > 0
  174. ) {
  175. f.extInfo.positionList.forEach((o) => {
  176. if (Object.prototype.hasOwnProperty.call(o, "sampleNum") && o.sampleNum >= 1) {
  177. _count = _count + Number(o.sampleNum);
  178. }
  179. });
  180. }
  181. });
  182. if (_count < 1) {
  183. uni.showToast({
  184. icon: "none",
  185. title: "请先取样",
  186. });
  187. return false;
  188. }
  189. let param = {
  190. taskId: this.taskId,
  191. workOrderId: this.id,
  192. quantity: _count
  193. }
  194. qualityQy(param).then(res => {
  195. this.$set(this.List[0], 'semiProductList', res)
  196. this.$forceUpdate()
  197. })
  198. },
  199. save() {
  200. batchSave(this.List).then((res) => {
  201. uni.navigateBack();
  202. });
  203. },
  204. handAdd(id) {
  205. console.log(id);
  206. const storageKey = Date.now() + "";
  207. uni.setStorageSync(storageKey, this.List || []);
  208. uni.navigateTo({
  209. url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.taskId}&classIds=[4,7]`,
  210. });
  211. },
  212. },
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. .content-box {
  217. height: 100vh;
  218. overflow: hidden;
  219. display: flex;
  220. flex-direction: column;
  221. }
  222. .list_box {
  223. flex: 1;
  224. overflow: hidden;
  225. padding: 4rpx 0;
  226. .u-list {
  227. height: 100% !important;
  228. }
  229. .card_box {
  230. padding: 16rpx 24rpx;
  231. }
  232. }
  233. .bottom-wrapper {
  234. .btn_box {
  235. width: 750rpx;
  236. height: 88rpx;
  237. line-height: 88rpx;
  238. background: $theme-color;
  239. text-align: center;
  240. font-size: 36rpx;
  241. font-style: normal;
  242. font-weight: 400;
  243. color: #fff;
  244. }
  245. }
  246. .operate_box {
  247. padding: 10rpx 20rpx;
  248. /deep/ .u-button {
  249. width: 160rpx;
  250. }
  251. }
  252. </style>