| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <template>
- <view class="content-box">
- <uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#F7F9FA"
- color="#000" @clickLeft="back">
- </uni-nav-bar>
- <view class="list_box">
- <u-list @scrolltolower="scrolltolower">
- <view class="card_box" v-for="(item, index) in List" :key="index">
- <workOrderBom :item="item" v-if="item" @handleScan="handleWordScan"></workOrderBom>
- <deviceBom v-if="item.equipmentList.length != 0" :workOrderId="item.workOrderId"
- :list="item.equipmentList" @scanIt="scanIt"></deviceBom>
- <turnoverBom v-if="item.turnover.length != 0" :list="item.turnover" :wordItem="item" pattern="job">
- </turnoverBom>
- <view class="operate_box rx-sc">
- <u-button size="small" class="u-reset-button" type="success"
- @click="handAdd(item.workOrderId)">手动添加</u-button>
- <u-button size="small" class="u-reset-button" type="success"
- @click="scanIt(item.workOrderId)">扫一扫</u-button>
- <u-button size="small" class="u-reset-button" type="success" @click="handQuality">质检</u-button>
- </view>
- <diagramLast v-if="item && Object.prototype.hasOwnProperty.call(item, 'lastObj') &&
- item.workOrderType !=2" :item="item.lastObj"></diagramLast>
- <inspectionBom
- v-if='Object.prototype.hasOwnProperty.call(item, "semiProductList") && item.semiProductList'
- :semiProductList='item.semiProductList'></inspectionBom>
- </view>
- </u-list>
- </view>
- <view class="bottom-wrapper">
- <view class="btn_box" @click="save">确认</view>
- </view>
- </view>
- </template>
- <script>
- import {
- workorderList,
- scanLedger,
- qualityQy
- } from "@/api/pda/workOrder.js";
- import {
- batchSave
- } from "@/api/pda/feeding.js";
- import workOrderBom from "../../feeding/components/workOrderBom.vue";
- import inspectionBom from "../components/inspectionBom.vue";
- import deviceBom from "../../feeding/components/deviceBom.vue";
- import diagramLast from "../components/diagramLast.vue";
- import turnoverBom from "../../sample/components/turnoverBom.vue";
- export default {
- components: {
- workOrderBom,
- inspectionBom,
- deviceBom,
- diagramLast,
- turnoverBom,
- },
- data() {
- return {
- title: null,
- id: null,
- taskId: null,
- List: [],
- };
- },
- onLoad(options) {
- this.title = options.taskName || '质检'
- this.id = options.workOrderId;
- this.taskId = options.taskId;
- this.getList();
- },
- onShow() {
- uni.$off("setSelectList");
- uni.$on("setSelectList", (selectList, id) => {
- this.List.forEach((m) => {
- if (m.workOrderId == id) {
- let equipmentList = []; // 生产设备
- let turnover = [];
- selectList.forEach((f) => {
- if (f.rootCategoryLevelId == 4) {
- equipmentList = equipmentList.concat(f);
- }
- if (f.rootCategoryLevelId == 7) {
- turnover = turnover.concat(f);
- }
- });
- this.$set(m, "equipmentList", equipmentList);
- this.$set(m, "turnover", turnover);
- }
- });
- });
- },
- methods: {
- getList() {
- workorderList({
- ids: [this.id],
- taskId: this.taskId,
- }).then((res) => {
- this.List = res.map((m) => {
- m.workOrderId = m.id;
- m.equipmentList = []; // 设备
- m.turnover = []; // 周转车
- m.lastObj = {
- formedNum: m.formedNumLast,
- taskNameLast: m.taskNameLast,
- unit: m.unit,
- };
- m.feedType = 3;
- delete m.id;
- if (this.taskId) {
- m.taskId = this.taskId;
- }
- return {
- ...m,
- };
- });
- });
- },
- scrolltolower() {},
- handleWordScan() {
- uni.showToast({
- icon: "none",
- title: "不支持换工单",
- });
- },
- scanIt(id) {
- uni.scanCode({
- success: (res) => {
- this.scanItData(res.result, id);
- },
- });
- },
- scanItData(result, id) {
- scanLedger(result).then((res) => {
- let _arr = [];
- if (res.length == 1 && res[0].rootCategoryLevelId == 4) {
- // 设备
- _arr = this.List;
- _arr.forEach((e, index) => {
- if (e.workOrderId == id) {
- _arr[index].equipmentList = res;
- }
- });
- this.List = _arr;
- this.$forceUpdate();
- }
- if (res.length == 1 && res[0].rootCategoryLevelId == 7) {
- // 周转车
- _arr = this.List;
- _arr.forEach((e, index) => {
- if (e.workOrderId == id) {
- _arr[index].turnover = res;
- }
- });
- this.List = _arr;
- this.$forceUpdate();
- }
- });
- },
- handQuality() {
- console.log(this.List[0]);
- if (this.List[0].turnover.length == 0) {
- uni.showToast({
- icon: "none",
- title: "请先添加周转车取样",
- });
- return false;
- }
- let _count = 0;
- this.List[0].turnover &&
- this.List[0].turnover.forEach((f) => {
- if (
- f.extInfo &&
- f.extInfo.positionList &&
- f.extInfo.positionList.length > 0
- ) {
- f.extInfo.positionList.forEach((o) => {
- if (Object.prototype.hasOwnProperty.call(o, "sampleNum") && o.sampleNum >= 1) {
- _count = _count + Number(o.sampleNum);
- }
- });
- }
- });
- if (_count < 1) {
- uni.showToast({
- icon: "none",
- title: "请先取样",
- });
- return false;
- }
- let param = {
- taskId: this.taskId,
- workOrderId: this.id,
- quantity: _count
- }
- qualityQy(param).then(res => {
- this.$set(this.List[0], 'semiProductList', res)
- this.$forceUpdate()
- })
- },
- save() {
- batchSave(this.List).then((res) => {
- uni.navigateBack();
- });
- },
- handAdd(id) {
- console.log(id);
- const storageKey = Date.now() + "";
- uni.setStorageSync(storageKey, this.List || []);
- uni.navigateTo({
- url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}&isType=zdy&taskId=${this.taskId}&classIds=[4,7]`,
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .content-box {
- height: 100vh;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- }
- .list_box {
- flex: 1;
- overflow: hidden;
- padding: 4rpx 0;
- .u-list {
- height: 100% !important;
- }
- .card_box {
- padding: 16rpx 24rpx;
- }
- }
- .bottom-wrapper {
- .btn_box {
- width: 750rpx;
- height: 88rpx;
- line-height: 88rpx;
- background: $theme-color;
- text-align: center;
- font-size: 36rpx;
- font-style: normal;
- font-weight: 400;
- color: #fff;
- }
- }
- .operate_box {
- padding: 10rpx 20rpx;
- /deep/ .u-button {
- width: 160rpx;
- }
- }
- </style>
|