| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <template>
- <view class="">
- <uni-nav-bar background-color="#157A2C" color="#fff" fixed="true" statusBar="true" left-icon="back" title="配件申请"
- @clickLeft="back">
- </uni-nav-bar>
- <u-subsection :list="list" :current="current" @change="sectionChange"></u-subsection>
- <u-cell-group v-show="current == 0">
- <u-cell title="编码" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <u--input disabled style="flex:1" border="surround" v-model="form.code">
- </u--input>
- </view>
- </u-cell>
- <u-cell title="名称" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <u--input readonly placeholder="请输入" style="flex:1" border="surround" v-model="form.name">
- </u--input>
- </view>
- </u-cell>
- <u-cell title="领用部门" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <u--input readonly placeholder="请输入" style="flex:1" border="surround"
- v-model="form.receivingDeptName">
- </u--input>
- </view>
- </u-cell>
- <u-cell title="领用人" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <u--input readonly placeholder="请输入" style="flex:1" border="surround" v-model="form.recipientName">
- </u--input>
- </view>
- </u-cell>
- <u-cell title="使用时间" arrow-direction="down">
- <uni-datetime-picker type="datetime" slot="value" v-model="form.usageTime">
- </uni-datetime-picker>
- </u-cell>
- <u-cell title="部门" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <u--input style="flex:1" placeholder="请选择" border="surround" @click.native="selectDepartment"
- v-model="form.useDeptName">
- </u--input>
- </view>
- </u-cell>
- <u-cell title="使用人" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <zxz-uni-data-select class="executor_user" :localdata="userList" v-model="form.userId"
- @change="handleUserChange" :multiple="Usertype==2"></zxz-uni-data-select>
- </view>
- </u-cell>
- <u-cell title="用途" arrow-direction="down">
- <view slot="value" style="display: flex;align-items: center;width: 100%;">
- <u--textarea style="flex:1" border="surround" placeholder="请输入内容"
- v-model="form.purpose"></u--textarea>
- </view>
- </u-cell>
- </u-cell-group>
- <accessoryList ref="accessoryRef" :itemList="tableList" v-show="current == 1" />
- <view class="footerButton">
- <u-button type="default" text="返回" @click="back"></u-button>
- <u-button type="primary" @click="save" text="保存"></u-button>
- </view>
- <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
- valueKey="id" textKey="name" childrenKey="children" />
- <u-toast ref="uToast"></u-toast>
- </view>
- </template>
- <script>
- import accessoryList from './accessoryList.vue';
- import {
- getByCode
- } from '@/api/pda/common.js'
- import {
- listOrganizations,
- getUserPage
- } from '@/api/myTicket/index.js'
- import {
- getSalesWorkOrderById,
- saveOrUpdateSalesWorkOrder
- } from '@/api/salesServiceManagement/workOrder/index.js'
- export default {
- components: {
- accessoryList
- },
- computed: {
- },
- data() {
- return {
- current: 0,
- type: 'edit',
- form: {
- name: '',
- receivingDeptName: '',
- receivingDeptId: '',
- recipientName: '',
- recipientId: '',
- purpose: '',
- useDeptId: '',
- useDeptName: '',
- userName: '',
- userId: '',
- usageTime: ''
- },
- Usertype: '',
- list: ['基本信息', '配件信息'],
- listData: [], // 部门数据
- userList: [], // 执行人列表
- tableList: [], // 配件列表
- }
- },
- onLoad(params) {
- this.type = params.type;
- this.title = params.type == 'view' ? '工单详情' : '修改工单';
- this.getDetails(params.id);
- },
- onUnload() {},
- created() {},
- methods: {
- async getDetails(id) {
- let data = await getSalesWorkOrderById(id);
- this.tableList = data.costListVOS.filter((item) => {
- if (item.typeId == 2 && item.isApply != 1) {
- item.totalPrice = item.settlementPrice;
- item.categoryCode = item.code;
- item.categoryName = item.name;
- return item;
- }
- })
- this.form.receivingDeptName = data.executeGroupName;
- this.form.receivingDeptId = data.executeGroupId;
- this.form.recipientName = data.executeUserName;
- this.form.recipientId = data.executeUserId;
- this.form.name = data.name;
- this.form.id = data.id;
- this.getDept();
- },
- getDept() {
- listOrganizations(1).then(data => {
- this.listData = data;
- })
- },
- confirm(data, name) {
- this.form.useDeptName = name
- this.form.useDeptId = data[0]
- this.form.userName = ''
- this.form.userId = ''
- this.getUser(data[0])
- },
- getUser(deptCode) {
- getUserPage({
- pageNum: 1,
- size: -1,
- groupId: deptCode
- }).then(data => {
- this.userList = data.list.map(item => {
- item.text = item.name;
- item.value = item.id;
- return item;
- })
- })
- },
- sectionChange(index) {
- this.current = index;
- },
- // 选择部门
- selectDepartment() {
- this.$refs.treePicker._show();
- },
- // 选择人
- handleUserChange(obj) {
- this.form.userName = obj.name;
- },
- save() {
- if (!this.form.usageTime) {
- this.$refs.uToast.show({
- type: "warning",
- message: "请选择使用时间",
- })
- return;
- }
- if (!this.form.useDeptName) {
- this.$refs.uToast.show({
- type: "warning",
- message: "请选择部门",
- })
- return;
- }
- if (!this.form.userName) {
- this.$refs.uToast.show({
- type: "warning",
- message: "请选择执行人",
- })
- return;
- }
- let list = this.$refs.accessoryRef.getTabData();
- let form = JSON.parse(JSON.stringify(this.form));
- let arr = form.usageTime.split(' ');
- if (!arr[1]) {
- form.usageTime = form.usageTime + ' 00:00:00'
- }
- const data = {
- ...form,
- details: list
- }
- uni.showLoading({
- title: '加载中'
- })
- saveOrUpdateSalesWorkOrder(data).then((res) => {
- this.$refs.uToast.show({
- type: "success",
- message: "操作成功",
- })
- uni.hideLoading();
- this.back();
- }).catch((e) => {
- uni.hideLoading();
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/.u-subsection__item__text {
- font-size: 28rpx !important;
- }
- /deep/.u-cell__body__content {
- flex: none;
- margin-right: 16rpx;
- }
- /deep/ .time_select .uni-data-tree-input {
- width: 200rpx;
- }
- /deep/ .executor_user {
- background: #fff;
- }
- .footerButton {
- width: 100%;
- height: 84rpx;
- display: flex;
- position: fixed;
- bottom: 0;
- z-index: 10;
- /deep/.u-button {
- height: 100%;
- }
- >view {
- flex: 1;
- }
- }
- </style>
|