| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405 |
- <template>
- <view class="mainBox">
- <uni-nav-bar
- fixed="true"
- statusBar="true"
- left-icon="back"
- :title="`${title}-准备`"
- @clickLeft="back"
- >
- <view class="nav-right" slot="right">
- <view class="text-box" @click="addMaterial"> 添加物料 </view>
- </view>
- </uni-nav-bar>
- <uni-forms
- class="list"
- ref="form"
- :modelValue="formData"
- :rules="rules"
- validate-trigger="blur"
- >
- <div
- class="list-item"
- v-for="(item, index) in formData.list"
- :key="index"
- >
- <div class="item-title" @click="showContent(item)">
- <div>
- 物料编码 <span>{{ item.code }}</span>
- </div>
- <div class="title-delt" @click="remove(item, index)">删除</div>
- <!-- <image src="~@/static/product/xl.svg" :style="item.show?'transform: rotate(180deg)':''"></image> -->
- </div>
- <div class="item-content">
- <!-- v-if="item.show" -->
- <template>
- <div class="content-line">
- <div class="line-left">
- <span>物料名称</span>
- <p>{{ item.name }}</p>
- </div>
- </div>
- <!-- <div class="content-line">
- <div class="line-left">
- <span>类型</span>
- <p>{{ item.categoryLevelGroupName }}</p>
- </div>
- </div> -->
- <div class="content-line">
- <div class="line-left">
- <span>牌号</span>
- <p>{{ item.brandNum }}</p>
- </div>
- </div>
- <div class="content-line">
- <div class="line-left">
- <span>型号</span>
- <p>{{ item.model }}</p>
- </div>
- </div>
- <div class="content-line">
- <div class="line-left">
- <span>需求数量</span>
- <p>
- <!-- :rules="[{'required': true,errorMessage: '生产数量必填'},{pattern:/^[1-9]\d*$/,errorMessage: '请输入正整数',trigger: 'blur'}]" -->
- <uni-forms-item
- ref="input"
- :key="item.id"
- :name="['list', index, 'demandWeight']"
- style="margin-top: 30rpx"
- >
- <uni-easyinput
- size="small"
- type="number"
- v-model="item.demandWeight"
- />
- </uni-forms-item>
- PCS
- </p>
- </div>
- <div class="line-right">
- <u-button
- class="right-minus"
- @click="reduce(item, index)"
- :disabled="item.demandWeight < 2"
- >-</u-button
- >
- <u-button class="right-add" @click="add(item, index)"
- >+</u-button
- >
- </div>
- </div>
- <div class="content-line">
- <div class="line-left">
- <span>仓库</span>
- <uni-forms-item
- ref="input"
- :rules="[{ required: true, errorMessage: '仓库是必选' }]"
- :key="item.id"
- :name="['list', index, 'warehouse']"
- style="margin-top: 40rpx"
- >
- <uni-easyinput
- :value="item.warehouse"
- readonly
- placeholder="请输入"
- size="small"
- @click.native="choose(item, index)"
- />
- </uni-forms-item>
- </div>
- </div>
- <!-- <div class="content-delt" @click="remove(item,index)">删除</div> -->
- </template>
- <!-- <div class="content-line" v-else>
- <span>{{ item.name }}</span>
- <div class="line-right">
- 400{{item.measuringUnit}}
- </div>
- </div> -->
- </div>
- </div>
- </uni-forms>
- <div class="footer">
- <div class="footer-btn" @click="submit">领料</div>
- </div>
- <locationPopu
- ref="locationRef"
- @checkLocation="comfirmLocation"
- ></locationPopu>
- <materialDialog
- ref="materialDialogRef"
- @affirm="comfirmChoose"
- :chooseList="formData.list"
- :params="materialPar"
- />
- </view>
- </template>
- <script>
- import { post, postJ, get, getJ } from "@/utils/api.js";
- import materialDialog from "./components/materialDialog.vue";
- import locationPopu from "../components/locationPopu.vue";
- import { batchSave, getLoginUser } from "@/api/production/extrusion.js";
- export default {
- components: {
- materialDialog,
- locationPopu,
- },
- data() {
- return {
- title: "挤压成型",
- formData: {
- list: [],
- },
- rules: {},
- chooseIndex: null,
- code: "",
- id: "",
- userInfo: {},
- //正整数正则 /^[1-9]\d*$/
- materialPar: {},
- };
- },
- onLoad({ id, code, taskInstanceId, versionId }) {
- if (id) {
- this.id = id;
- }
- if (code) {
- this.code = code;
- }
- this.materialPar = {
- taskInstanceId,
- versionId,
- };
- this.getUserInfo();
- },
- methods: {
- showContent(item) {
- this.$set(item, "show", !item.show);
- },
- remove(item, index) {
- this.formData.list.splice(index, 1);
- },
- reduce(item, index) {
- this.$set(
- this.formData.list[index],
- "demandWeight",
- Number(item.demandWeight) - 1
- );
- },
- add(item, index) {
- this.$set(
- this.formData.list[index],
- "demandWeight",
- Number(item.demandWeight) + 1
- );
- },
- choose(item, index) {
- this.chooseIndex = index;
- this.$refs.locationRef.open();
- },
- submit() {
- this.$refs.form
- .validate()
- .then((res) => {
- batchSave({
- ...this.userInfo,
- pickOrderList: this.formData.list,
- }).then((res) => {
- if (res) {
- uni.$u.toast("提交成功!");
- uni.navigateBack({
- delta: 1,
- });
- }
- });
- })
- .catch((err) => {
- uni.$u.toast("请补全信息!");
- });
- },
- addMaterial() {
- this.$refs.materialDialogRef.open();
- },
- comfirmChoose(list) {
- // 取出在弹窗中选中并且不在表格中的数据
- list = list.map((item) => ({
- ...item,
- name: item.categoryName,
- code: item.categoryCode,
- sourceCategoryId: item.id,
- brandNum: item.brandNum,
- factoryCode: item.factoryCode,
- }));
- const result = list.filter(
- (i) => this.formData.list.findIndex((p) => p.id === i.id) === -1
- );
- // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
- const del = this.formData.list.filter(
- (i) => list.findIndex((p) => p.id === i.id) === -1
- );
- for (let i = this.formData.list.length - 1; i >= 0; i--) {
- for (let j in del) {
- if (this.formData.list[i].id === del[j].id) {
- this.formData.list.splice(i, 1);
- }
- }
- }
- this.formData.list = this.formData.list.concat(
- result.map((item, index) => {
- this.$set(item, "demandWeight", 0);
- this.$set(item, "warehouse", "");
- this.$set(item, "warehouseId", "");
- this.$set(item, "workOrderCode", this.code);
- this.$set(item, "workOrderId", this.id);
- return item;
- })
- );
- },
- comfirmLocation(cho) {
- if (cho.warehouseId) {
- this.$set(
- this.formData.list[this.chooseIndex],
- "warehouseId",
- cho.warehouseId
- );
- this.$set(
- this.formData.list[this.chooseIndex],
- "warehouse",
- cho.warehouse
- );
- }
- },
- getUserInfo() {
- getLoginUser().then((res) => {
- this.userInfo.executorId = res.accountId;
- this.userInfo.executorName = res.name;
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .list {
- width: 94%;
- margin: 0 auto;
- padding: 0 0 100rpx;
- .list-item {
- width: 100%;
- margin: 20rpx auto 40rpx;
- .item-title {
- padding: 0 12rpx;
- border-bottom: 1rpx solid #ccc;
- display: flex;
- align-items: center;
- justify-content: space-between;
- font-size: 30rpx;
- color: #000;
- font-weight: bold;
- height: 80rpx;
- line-height: 80rpx;
- image {
- width: 21rpx;
- height: 11rpx;
- }
- span {
- margin-left: 15rpx;
- }
- .title-delt {
- color: #ec808d;
- // margin: 30rpx auto 0;
- width: 100rpx;
- text-align: center;
- }
- }
- .item-content {
- .content-line {
- padding: 0 12rpx;
- border-bottom: 1rpx dashed #ccc;
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 80rpx;
- line-height: 80rpx;
- .line-left {
- display: flex;
- align-items: center;
- justify-content: flex-start;
- span {
- width: 180rpx;
- text-align: left;
- color: rgb(127, 127, 127);
- }
- p {
- color: #333333;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- /deep/.uni-easyinput {
- width: 220rpx;
- margin-right: 10rpx;
- height: 20rpx !important;
- .uni-easyinput__content {
- height: 70rpx !important;
- }
- }
- }
- }
- .line-right {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .right-minus {
- width: 80rpx;
- height: 51rpx;
- text-align: center;
- line-height: 51rpx;
- color: #fff;
- background: #f59a23;
- border: none;
- }
- .right-add {
- width: 80rpx;
- height: 51rpx;
- text-align: center;
- line-height: 51rpx;
- color: #fff;
- background: #70b603;
- margin-left: 10rpx;
- border: none;
- }
- .right-add.right-choose {
- width: 120rpx;
- }
- }
- }
- }
- }
- }
- .footer {
- width: 100%;
- height: 90rpx;
- position: fixed;
- bottom: 0;
- left: 0;
- .footer-btn {
- width: 100%;
- height: 90rpx;
- line-height: 90rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 34rpx;
- color: #fff;
- background: #70b603;
- }
- }
- </style>
|