| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <template>
- <view class="assign-container">
- <u-popup :show="popShow" @close="close">
- <view class="select-container">
- <view class="title">
- <text class="btn cancel" @tap="close">取消</text>
- 工单转派
- <text class="btn confirm" @tap="submit">确定</text>
- </view>
- <view class="select-wrapper">
- <view class="col userInp" v-if="fromValue=='Transfer'">
- <text class="label">类型:</text>
- <!-- multiple -->
- <zxz-uni-data-select :localdata="[{text:'执行人',value:1},{text:'辅助人',value:2}]" v-model="Usertype"
- @change="changeUserType"></zxz-uni-data-select>
- </view>
- <!-- fromValue Transfer -->
- <view class="col deptInp">
- <text class="label">部门:</text>
- <!-- <input type="text" disabled :value="formData.executorDeptName" placeholder="请选择" /> -->
- <text class="input_text"
- @click="openPicker">{{ formData.executorDeptName ? formData.executorDeptName : '请选择' }}</text>
- </view>
- <view class="col userInp">
- <text class="label">接收人:</text>
- <!-- multiple -->
- <zxz-uni-data-select :localdata="userList" v-model="formData.executorId"
- @change="handleUserChange" :multiple="Usertype==2"></zxz-uni-data-select>
- </view>
- <!-- <view class="col userInp">
- <text class="label">转派原因:</text>
- <textarea v-model="formData.reassignExplain" cols="20" rows="5"></textarea>
- </view> -->
- </view>
- </view>
- </u-popup>
- <ba-tree-picker ref="treePicker" :multiple="false" @select-change="confirm" title="选择部门" :localdata="listData"
- valueKey="id" textKey="name" childrenKey="children" />
- </view>
- </template>
- <script>
- import {
- listOrganizations,
- getUserPage,
- workOrderRotate,
- addAssists
- } from '@/api/myTicket/index.js'
- import {
- post,
- get,
- postJ
- } from '@/utils/api.js'
- import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
- export default {
- components: {
- baTreePicker
- },
- data() {
- return {
- popShow: false,
- deptPickerShow: false,
- listData: [],
- userList: [],
- formData: {
- executorDeptName: '',
- executorName: '',
- executorId: '',
- reassignExplain: '',
- workOrderId: ''
- },
- selectList: [],
- newArr: [],
- Usertype: '',
- fromValue: ''
- }
- },
- created() {
- this.getDept()
- },
- methods: {
- //工单id
- open(id, val) {
- console.log(id, val)
- this.fromValue = val
- this.formData.workOrderId = id
- this.popShow = true
- },
- openPicker() {
- this.$refs.treePicker._show()
- },
- changeUserType() {
- this.formData.executorId = ''
- this.formData.executorName = ''
- },
- deWeight(arr4) {
- var obj = {}
- arr4 = arr4.reduce(function(a, b) {
- obj[b.userId] ? '' : (obj[b.userId] = true && a.push(b))
- return a
- }, [])
- return arr4
- },
- handleUserChange(obj) {
- if (this.Usertype == 1) {
- this.formData.executorName = obj.name
- } else {
- this.formData.executorId = this.formData.executorId.toString()
- }
- // const obj = this.userList.find(i => i.value === id)
- // this.formData.executorName = (obj && obj.text) || ''
- },
- close() {
- this.formData = {
- executorDeptName: '',
- executorName: '',
- executorId: '',
- reassignExplain: '',
- workOrderId: ''
- }
- this.popShow = false
- },
- submit() {
- if (!this.formData.executorId) {
- uni.showToast({
- icon: 'error',
- title: '请选择接收人'
- })
- return
- }
- // if (!this.formData.reassignExplain) {
- // uni.showToast({
- // icon: 'error',
- // title: '请输入转派原因'
- // })
- // return
- // }
- // let param = {
- // executorDeptName: this.formData.executorDeptName,
- // executorName: this.formData.executorName,
- // executorId: this.formData.executorId,
- // reassignExplain: this.formData.reassignExplain,
- // workOrderId: this.formData.workOrderId
- // }
- let param = {
- acceptUserId: this.formData.executorId,
- workOrderId: this.formData.workOrderId
- }
- console.log(param, 'param')
- if (this.Usertype == 1) {
- workOrderRotate(param).then(() => {
- this.close()
- const _this = this
- uni.showModal({
- title: `此工单已转派成功`,
- content: '',
- confirmText: '确认',
- showCancel: false, // 是否显示取消按钮,默认为 true
- success: function(res) {
- if (res.confirm) {
- _this.$emit('success', _this.formData)
- }
- }
- })
- })
- } else {
- addAssists(param).then(() => {
- this.close()
- const _this = this
- uni.showModal({
- title: `此工单已转派成功`,
- content: '',
- confirmText: '确认',
- showCancel: false, // 是否显示取消按钮,默认为 true
- success: function(res) {
- if (res.confirm) {
- _this.$emit('success', _this.formData)
- }
- }
- })
- })
- }
- // postJ(this.apiUrl + '/workOrder/anewSendOrders', [param]).then(res => {
- // if (res?.success) {
- // this.close()
- // const _this = this
- // uni.showModal({
- // title: `此工单已转派成功`,
- // content: '',
- // confirmText: '确认',
- // showCancel: false, // 是否显示取消按钮,默认为 true
- // success: function (res) {
- // if (res.confirm) {
- // _this.$emit('success', _this.formData)
- // }
- // }
- // })
- // // uni.showToast({
- // // icon: 'success',
- // // title: '转派成功!',
- // // mask: true
- // // })
- // // setTimeout(() => {
- // // }, 1500)
- // }
- // })
- },
- confirm(data, name) {
- console.log(data)
- console.log(name)
- this.formData.executorDeptName = name
- this.formData.executorDeptCode = data[0]
- this.formData.executorName = ''
- this.formData.executorId = ''
- this.getUser(data[0])
- },
- getDept() {
- listOrganizations(1).then(data => {
- console.log('listOrganizations-----------------------')
- console.log(data)
- this.listData = data
- })
- // get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
- // if (res?.success) {
- // this.listData = res.data
- // }
- // })
- },
- 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
- })
- })
- // post(this.apiUrl + '/main/user/list', {
- // deptCode,
- // page: 1,
- // size: 9999
- // }).then(res => {
- // if (res?.success) {
- // this.userList = res.data.items.map(item => {
- // item.text = item.trueName
- // item.value = item.userId
- // return item
- // })
- // }
- // })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .select-container {
- min-height: 60vh;
- .title {
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 100rpx;
- line-height: 100rpx;
- text-align: center;
- background-color: $j-primary-border-green;
- font-weight: bold;
- padding: 0 20rpx;
- position: relative;
- font-size: 32rpx;
- color: #fff;
- .btn {
- width: 80rpx;
- height: 32rpx;
- display: inline-block;
- font-size: 32rpx;
- border: 1px solid #fff;
- text-align: center;
- line-height: 30rpx;
- margin: 0;
- }
- }
- .select-wrapper {
- .col {
- display: flex;
- // min-height: 0rpx;
- margin-top: 22rpx;
- align-items: center;
- padding-right: 14rpx;
- .label {
- display: inline-block;
- width: 200rpx;
- text-align: right;
- }
- .input_text {
- flex: 1;
- height: 66rpx;
- line-height: 66rpx;
- padding: 0rpx 16rpx;
- box-sizing: border-box;
- font-size: 28rpx;
- border: 1px solid #eceeec;
- border-radius: 8rpx;
- }
- input {
- flex: 1;
- border: 1rpx solid #e5e5e5;
- height: 66rpx;
- border-radius: 8rpx;
- font-size: 28rpx;
- padding: 0rpx 16rpx;
- color: #6a6a6a;
- }
- textarea {
- border: 1rpx solid #e5e5e5;
- flex: 1;
- height: 100rpx;
- }
- .tab_box {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- width: 520rpx;
- .tab {
- display: flex;
- flex-direction: row;
- border: 2rpx solid #d9ecff;
- background-color: #f4f4f5;
- border-color: #e9e9eb;
- color: #909399;
- margin-left: 8rpx;
- margin-bottom: 8rpx;
- padding: 2rpx 8rpx;
- font-size: 28rpx;
- }
- .icon {
- margin-left: 6rpx;
- }
- }
- }
- }
- }
- </style>
|