index.vue 8.3 KB

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