| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309 |
- <template>
- <view class="mainBox">
- <uni-nav-bar
- fixed="true"
- statusBar="true"
- left-icon="back"
- title="调拨预览"
- @clickLeft="back"
- >
- <!--右菜单-->
- <template slot="right">
- <text class="roughDraft" @click="handleSaveToRoughDraft"
- >保存为草稿</text
- >
- </template>
- </uni-nav-bar>
- <view class="view-container">
- <DetailView
- :baseInfo="baseInfo.conventionalStockTransferReq"
- :list="baseInfo.infoReqList"
- type="view"
- />
- </view>
- <view class="footer">
- <view class="verify-box">
- <u-input
- class="dept"
- :value="baseInfo.conventionalStockTransferReq.deptName"
- disableColor="#ffffff"
- placeholder="请选择审批部门"
- @click.native="$refs.treePicker._show()"
- disabled
- border="surround"
- >
- <u-icon
- v-show="baseInfo.conventionalStockTransferReq.deptName"
- slot="suffix"
- name="close-circle-fill"
- @click.native.stop="verifyDeptConfirm([])"
- ></u-icon>
- </u-input>
- <picker
- @change="(e) => handlePicker(e, userList, 'auditorId', 'auditorName')"
- :value="0"
- :disabled="!baseInfo.conventionalStockTransferReq.deptName"
- :range="userList"
- range-key="name"
- >
- <u-input
- @click.native="handlMind"
- class="name"
- :value="baseInfo.conventionalStockTransferReq.auditorName"
- disableColor="#ffffff"
- placeholder="请选择审批人"
- disabled
- border="surround"
- >
- <u-icon
- slot="suffix"
- name="close-circle-fill"
- v-show="baseInfo.conventionalStockTransferReq.auditorName"
- @click.native.stop="clearAuditor"
- ></u-icon>
- </u-input>
- </picker>
- </view>
- <u-button type="primary" @click="handleSave">提交审核</u-button>
- </view>
- <ba-tree-picker
- ref="treePicker"
- :multiple="false"
- @select-change="verifyDeptConfirm"
- key="dept"
- title="选择部门"
- :localdata="deptList"
- valueKey="code"
- textKey="name"
- childrenKey="children"
- />
- </view>
- </template>
- <script>
- import baTreePicker from "@/components/ba-tree-picker/ba-tree-picker.vue";
- import DetailView from "./components/DetailView.vue";
- import { post, postJ, get, getJ } from "@/utils/api.js";
- export default {
- components: { DetailView, baTreePicker },
- data() {
- return {
- activeName: 1,
- baseInfo: {
- conventionalStockTransferReq: {
- deptCode: "",
- deptName: "",
- auditorId: "",
- auditorName: "",
- },
- },
- assetsList: [],
- deptList: [],
- userList: [],
- loading: false,
- };
- },
- onLoad({ id }) {
- if (id) {
- const storeInfo = uni.getStorageSync("inventoryAllocation_preview");
- const info = storeInfo[id] || {};
- this.baseInfo = info.params;
- this.assetsList = info.assetsList;
- }
- this.getDept();
- },
- methods: {
- handlMind() {
- if (this.baseInfo.conventionalStockTransferReq.deptName) {
- return;
- }
- uni.showToast({
- title: "请先选择部门",
- icon: "none",
- });
- },
- async handleSaveToRoughDraft() {
- delete this.baseInfo.conventionalStockTransferReq.createTime;
- const params = uni.$u.deepClone(this.baseInfo);
- params.infoReqList = [
- ...params.infoReqList,
- ...this.assetsList.map((item) => {
- item.detailReqList = item.curDetailReqList;
- return item;
- }),
- ];
- const res = await postJ(
- this.apiUrl + `/conventionalStockTransfer/saveDraft`,
- params,
- true
- );
- if (res?.success) {
- uni.showToast({
- title: "保存成功!",
- mask: true,
- });
- setTimeout(() => {
- uni.navigateBack({
- delta: 2,
- });
- }, 1500);
- }
- },
- async handleSave() {
- delete this.baseInfo.conventionalStockTransferReq.createTime;
- const res = await postJ(
- this.apiUrl + `/conventionalStockTransfer/add`,
- this.baseInfo,
- true,
- false
- ).catch((err) => {
- console.log(err);
- if (err.code === "B00000") {
- uni.showModal({
- title: "提示",
- content: err.message,
- showCancel: false,
- success: function (res) {},
- });
- }
- });
- if (res?.success) {
- uni.showToast({
- title: "提交成功!",
- mask: true,
- });
- setTimeout(() => {
- uni.navigateBack({
- delta: 2,
- });
- }, 1500);
- }
- },
- // 审核人保存
- handlePicker(e, list, idKey, nameKey) {
- if (idKey) {
- this.$set(
- this.baseInfo.conventionalStockTransferReq,
- idKey,
- list[e.detail.value].id
- );
- }
- if (nameKey) {
- this.$set(
- this.baseInfo.conventionalStockTransferReq,
- nameKey,
- list[e.detail.value].name
- );
- }
- console.log(this.baseInfo.conventionalStockTransferReq);
- },
- // 部门确认
- verifyDeptConfirm(data, name) {
- this.baseInfo.conventionalStockTransferReq.deptCode = data[0];
- this.baseInfo.conventionalStockTransferReq.deptName = name;
- this.$set(this.baseInfo.conventionalStockTransferReq, "auditorId", "");
- this.$set(this.baseInfo.conventionalStockTransferReq, "auditorName", "");
- if (data[0]) {
- this.getUser(data[0]);
- } else {
- this.userList = [];
- this.$refs.treePicker._reTreeList();
- }
- },
- clearAuditor() {
- this.$set(this.baseInfo.conventionalStockTransferReq, "auditorId", "");
- this.$set(this.baseInfo.conventionalStockTransferReq, "auditorName", "");
- },
- // 获取部门
- getDept() {
- get(this.apiUrl + "/main/org/dept/effectiveTree").then((res) => {
- if (res?.success) {
- this.deptList = res.data;
- }
- });
- },
- // 获取人员
- getUser(deptCode) {
- post(this.apiUrl + "/main/user/list", {
- deptCode,
- page: 1,
- size: 9999,
- }).then((res) => {
- if (res?.success) {
- this.userList = res.data.items.map((item) => {
- item.name = item.trueName;
- item.id = item.userId;
- return item;
- });
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .roughDraft {
- color: rgba(75, 121, 2, 1);
- white-space: nowrap;
- }
- .tabs {
- position: fixed;
- width: 100vw;
- background-color: rgba(242, 242, 242, 0.792156862745098);
- padding-top: 20rpx;
- display: flex;
- justify-content: flex-start;
- align-items: center;
- margin-bottom: 20rpx;
- .tab-item {
- width: 200rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- &.active {
- background: linear-gradient(
- 180deg,
- rgba(75, 121, 2, 1) 0%,
- rgba(255, 255, 255, 1) 12%
- );
- }
- }
- }
- .view-container {
- padding-bottom: 200rpx;
- }
- .footer {
- position: fixed;
- bottom: 0;
- width: 100vw;
- left: 0;
- background-color: #fff;
- .verify-box {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 10rpx;
- /deep/.u-input {
- border: 1rpx solid #ccc;
- }
- .dept.u-input {
- margin-right: 30rpx;
- }
- uni-picker {
- width: 40%;
- }
- }
- }
- </style>
|