preview.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="调拨预览" @clickLeft="back">
  4. <!--右菜单-->
  5. <template slot="right">
  6. <text class="roughDraft" @click="handleSaveToRoughDraft">保存为草稿</text>
  7. </template>
  8. </uni-nav-bar>
  9. <view class="view-container">
  10. <DetailView :baseInfo="baseInfo.conventionalStockTransferReq" :list="baseInfo.infoReqList" type="view" />
  11. </view>
  12. <view class="footer">
  13. <view class="verify-box">
  14. <u-input
  15. class="dept"
  16. :value="baseInfo.conventionalStockTransferReq.deptName"
  17. disableColor="#ffffff"
  18. placeholder="请选择审批部门"
  19. @click.native="$refs.treePicker._show()"
  20. disabled
  21. border="surround">
  22. <u-icon v-show="baseInfo.conventionalStockTransferReq.deptName" slot="suffix" name="close-circle-fill" @click.native.stop="verifyDeptConfirm([])"></u-icon>
  23. </u-input>
  24. <picker @change="e => handlePicker(e, userList, 'auditorId', 'auditorName')" :value="0" :disabled="!baseInfo.conventionalStockTransferReq.deptName" :range="userList" range-key="name">
  25. <u-input @click.native="handlMind" class="name" :value="baseInfo.conventionalStockTransferReq.auditorName" disableColor="#ffffff" placeholder="请选择审批人" disabled border="surround">
  26. <u-icon slot="suffix" name="close-circle-fill" v-show="baseInfo.conventionalStockTransferReq.auditorName" @click.native.stop="clearAuditor"></u-icon>
  27. </u-input>
  28. </picker>
  29. </view>
  30. <u-button type="primary" @click="handleSave">提交审核</u-button>
  31. </view>
  32. <ba-tree-picker ref="treePicker" :multiple="false" @select-change="verifyDeptConfirm" key="dept" title="选择部门" :localdata="deptList" valueKey="code" textKey="name" childrenKey="children" />
  33. </view>
  34. </template>
  35. <script>
  36. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  37. import DetailView from './components/DetailView.vue'
  38. import { post, postJ, get, getJ } from '@/utils/api.js'
  39. export default {
  40. components: { DetailView, baTreePicker },
  41. data() {
  42. return {
  43. activeName: 1,
  44. baseInfo: {
  45. conventionalStockTransferReq: {
  46. deptCode: '',
  47. deptName: '',
  48. auditorId: '',
  49. auditorName: ''
  50. }
  51. },
  52. assetsList: [],
  53. deptList: [],
  54. userList: [],
  55. loading: false
  56. }
  57. },
  58. onLoad({ id }) {
  59. if (id) {
  60. const storeInfo = uni.getStorageSync('inventoryAllocation_preview')
  61. const info = storeInfo[id] || {}
  62. this.baseInfo = info.params
  63. this.assetsList = info.assetsList
  64. }
  65. this.getDept()
  66. },
  67. methods: {
  68. handlMind() {
  69. if (this.baseInfo.conventionalStockTransferReq.deptName) {
  70. return
  71. }
  72. uni.showToast({
  73. title: '请先选择部门',
  74. icon: 'none'
  75. })
  76. },
  77. async handleSaveToRoughDraft() {
  78. // delete this.baseInfo.conventionalStockTransferReq.createTime;
  79. // const params = uni.$u.deepClone(this.baseInfo);
  80. // params.infoReqList = [
  81. // ...params.infoReqList,
  82. // ...this.assetsList.map((item) => {
  83. // item.detailReqList = item.curDetailReqList;
  84. // return item;
  85. // }),
  86. // ];
  87. // const res = await postJ(
  88. // this.apiUrl + `/conventionalStockTransfer/saveDraft`,
  89. // params,
  90. // true
  91. // );
  92. // if (res?.success) {
  93. // uni.showToast({
  94. // title: "保存成功!",
  95. // mask: true,
  96. // });
  97. // setTimeout(() => {
  98. // uni.navigateBack({
  99. // delta: 2,
  100. // });
  101. // }, 1500);
  102. // }
  103. },
  104. async handleSave() {
  105. // delete this.baseInfo.conventionalStockTransferReq.createTime
  106. // const res = await postJ(this.apiUrl + `/conventionalStockTransfer/add`, this.baseInfo, true, false).catch(err => {
  107. // console.log(err)
  108. // if (err.code === 'B00000') {
  109. // uni.showModal({
  110. // title: '提示',
  111. // content: err.message,
  112. // showCancel: false,
  113. // success: function (res) {}
  114. // })
  115. // }
  116. // })
  117. // if (res?.success) {
  118. // uni.showToast({
  119. // title: '提交成功!',
  120. // mask: true
  121. // })
  122. // setTimeout(() => {
  123. // uni.navigateBack({
  124. // delta: 2
  125. // })
  126. // }, 1500)
  127. // }
  128. },
  129. // 审核人保存
  130. handlePicker(e, list, idKey, nameKey) {
  131. if (idKey) {
  132. this.$set(this.baseInfo.conventionalStockTransferReq, idKey, list[e.detail.value].id)
  133. }
  134. if (nameKey) {
  135. this.$set(this.baseInfo.conventionalStockTransferReq, nameKey, list[e.detail.value].name)
  136. }
  137. console.log(this.baseInfo.conventionalStockTransferReq)
  138. },
  139. // 部门确认
  140. verifyDeptConfirm(data, name) {
  141. this.baseInfo.conventionalStockTransferReq.deptCode = data[0]
  142. this.baseInfo.conventionalStockTransferReq.deptName = name
  143. this.$set(this.baseInfo.conventionalStockTransferReq, 'auditorId', '')
  144. this.$set(this.baseInfo.conventionalStockTransferReq, 'auditorName', '')
  145. if (data[0]) {
  146. this.getUser(data[0])
  147. } else {
  148. this.userList = []
  149. this.$refs.treePicker._reTreeList()
  150. }
  151. },
  152. clearAuditor() {
  153. this.$set(this.baseInfo.conventionalStockTransferReq, 'auditorId', '')
  154. this.$set(this.baseInfo.conventionalStockTransferReq, 'auditorName', '')
  155. },
  156. // 获取部门
  157. getDept() {
  158. // get(this.apiUrl + '/main/org/dept/effectiveTree').then(res => {
  159. // if (res?.success) {
  160. // this.deptList = res.data
  161. // }
  162. // })
  163. },
  164. // 获取人员
  165. getUser(deptCode) {
  166. // post(this.apiUrl + "/main/user/list", {
  167. // deptCode,
  168. // page: 1,
  169. // size: 9999,
  170. // }).then((res) => {
  171. // if (res?.success) {
  172. // this.userList = res.data.items.map((item) => {
  173. // item.name = item.trueName;
  174. // item.id = item.userId;
  175. // return item;
  176. // });
  177. // }
  178. // });
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .roughDraft {
  185. color: rgba(75, 121, 2, 1);
  186. white-space: nowrap;
  187. }
  188. .tabs {
  189. position: fixed;
  190. width: 100vw;
  191. background-color: rgba(242, 242, 242, 0.792156862745098);
  192. padding-top: 20rpx;
  193. display: flex;
  194. justify-content: flex-start;
  195. align-items: center;
  196. margin-bottom: 20rpx;
  197. .tab-item {
  198. width: 200rpx;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. &.active {
  203. background: linear-gradient(180deg, rgba(75, 121, 2, 1) 0%, rgba(255, 255, 255, 1) 12%);
  204. }
  205. }
  206. }
  207. .view-container {
  208. padding-bottom: 200rpx;
  209. }
  210. .footer {
  211. position: fixed;
  212. bottom: 0;
  213. width: 100vw;
  214. left: 0;
  215. background-color: #fff;
  216. .verify-box {
  217. display: flex;
  218. justify-content: space-between;
  219. align-items: center;
  220. padding: 10rpx;
  221. /deep/.u-input {
  222. border: 1rpx solid #ccc;
  223. }
  224. .dept.u-input {
  225. margin-right: 30rpx;
  226. }
  227. uni-picker {
  228. width: 40%;
  229. }
  230. }
  231. }
  232. </style>