preview.vue 7.5 KB

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