reserve.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. <template>
  2. <view>
  3. <view style="padding:5rpx 20rpx 45rpx 20rpx;">
  4. <view class="desc">
  5. <uni-row>
  6. <uni-col :span="5">
  7. <view class="desc" style="font-size: 25rpx;">
  8. 申请人
  9. </view>
  10. </uni-col>
  11. <uni-col :span="19">
  12. <view>
  13. <uni-easyinput primaryColor="#37babd" v-model="form.applyUserName" disabled>
  14. </uni-easyinput>
  15. </view>
  16. </uni-col>
  17. </uni-row>
  18. </view>
  19. <view class="desc">
  20. <uni-row>
  21. <uni-col :span="5">
  22. <view class="desc" style="font-size: 25rpx;">
  23. 申请部门
  24. </view>
  25. </uni-col>
  26. <uni-col :span="19">
  27. <view class="pickerView">
  28. <picker @change="deptBindPickerChange" :value="deptConfig.deptIndex"
  29. :range="deptConfig.deptDatas" range-key="deptName">
  30. <view class="pickerText"
  31. v-if="deptConfig.deptDatas && deptConfig.deptDatas.length>0 && deptConfig.deptIndex !== undefined">
  32. {{ deptConfig.deptDatas[deptConfig.deptIndex].deptName }}
  33. </view>
  34. <view class="pickerText" v-else>
  35. {{defaultDept}}
  36. </view>
  37. </picker>
  38. </view>
  39. </uni-col>
  40. </uni-row>
  41. </view>
  42. <view class="desc" v-if="pageType === 'dj'">
  43. <uni-row>
  44. <uni-col :span="5">
  45. <view class="desc" style="font-size: 25rpx;">
  46. 登记类型
  47. </view>
  48. </uni-col>
  49. <uni-col :span="19">
  50. <view class="pickerView">
  51. <picker @change="accessBindPickerChange" :value="accessStorageType.index"
  52. :range="accessStorageType.data" range-key="dictLabel">
  53. <view class="pickerText"
  54. v-if="accessStorageType.data && accessStorageType.data.length>0 && accessStorageType.index !== undefined">
  55. {{ accessStorageType.data[accessStorageType.index].dictLabel }}
  56. </view>
  57. <view class="pickerText" v-else>
  58. 待 选 择
  59. </view>
  60. </picker>
  61. </view>
  62. </uni-col>
  63. </uni-row>
  64. </view>
  65. <view class="desc" v-if="pageType === 'ly'">
  66. <uni-row>
  67. <uni-col :span="5">
  68. <view class="desc" style="font-size: 25rpx;">
  69. 领用类型
  70. </view>
  71. </uni-col>
  72. <uni-col :span="19">
  73. <view class="pickerView">
  74. <picker @change="dictBindPickerChange" :value="outStorageType.index"
  75. :range="outStorageType.data" range-key="dictLabel">
  76. <view class="pickerText"
  77. v-if="outStorageType.data && outStorageType.data.length>0 && outStorageType.index !== undefined">
  78. {{ outStorageType.data[outStorageType.index].dictLabel }}
  79. </view>
  80. <view class="pickerText" v-else>
  81. 待 选 择
  82. </view>
  83. </picker>
  84. </view>
  85. </uni-col>
  86. </uni-row>
  87. </view>
  88. <view class="desc" v-if="pageType === 'gh'">
  89. <uni-row>
  90. <uni-col :span="5">
  91. <view class="desc" style="font-size: 25rpx;">
  92. 物品状态
  93. </view>
  94. </uni-col>
  95. <uni-col :span="19">
  96. <view class="pickerView">
  97. <radio-group @change="radioChange">
  98. <uni-col :span="12" v-for="(item, index) in radiolist1">
  99. <label :key="item.value">
  100. <radio color="rgb(55,186,189)" :value="item.value" :checked="index === current">
  101. {{item.value}}
  102. </radio>
  103. </label>
  104. </uni-col>
  105. </radio-group>
  106. </view>
  107. </uni-col>
  108. </uni-row>
  109. </view>
  110. <view class="desc">
  111. <uni-row>
  112. <uni-col :span="5">
  113. <view class="desc" style="font-size: 25rpx;">
  114. 物资类型
  115. </view>
  116. </uni-col>
  117. <uni-col :span="19">
  118. <view class="pickerView">
  119. <picker @change="oneBindPickerChange" :value="typeData.oneTypeIndex"
  120. :range="typeData.oneType" range-key="goodsTypeName">
  121. <view class="pickerText"
  122. v-if="typeData.oneType && typeData.oneType.length>0 && typeData.oneTypeIndex !== undefined">
  123. {{ typeData.oneType[typeData.oneTypeIndex].goodsTypeName }}
  124. </view>
  125. <view class="pickerText" v-else>
  126. 待 选 择
  127. </view>
  128. </picker>
  129. </view>
  130. </uni-col>
  131. </uni-row>
  132. </view>
  133. <view class="desc">
  134. <uni-row>
  135. <uni-col :span="5">
  136. <view class="desc" style="font-size: 25rpx;">
  137. 具体分类
  138. </view>
  139. </uni-col>
  140. <uni-col :span="19">
  141. <view class="pickerView">
  142. <picker @change="twoBindPickerChange" :value="typeData.twoTypeIndex"
  143. :range="typeData.twoType" range-key="goodsTypeName"
  144. :disabled="typeData.twoTypeDisabled">
  145. <view class="pickerText"
  146. v-if="typeData.twoType && typeData.twoType.length>0 && typeData.oneTypeIndex !== undefined">
  147. {{ typeData.twoType[typeData.twoTypeIndex].goodsTypeName }}
  148. </view>
  149. <view class="pickerText" v-else @click="isTwoTypeShowModal()">
  150. 待 选 择
  151. </view>
  152. </picker>
  153. </view>
  154. </uni-col>
  155. </uni-row>
  156. </view>
  157. <view class="desc">
  158. <uni-row>
  159. <uni-col :span="5">
  160. <view class="desc" style="font-size: 25rpx;">
  161. 物资名称
  162. </view>
  163. </uni-col>
  164. <uni-col :span="19">
  165. <view class="pickerView pickerText">
  166. <view @click="openGoodsPopup" class="pickerText" v-if="form.goodsName">
  167. {{form.goodsName}}
  168. </view>
  169. <view @click="openGoodsPopup" class="pickerText" v-else>
  170. 待 选 择
  171. </view>
  172. </view>
  173. </uni-col>
  174. </uni-row>
  175. </view>
  176. <view class="desc">
  177. <uni-row>
  178. <uni-col :span="5">
  179. <view class="desc" style="font-size: 25rpx;">
  180. 单位
  181. </view>
  182. </uni-col>
  183. <uni-col :span="19">
  184. <view class="pickerView">
  185. <view class="pickerText" v-if="form.unit">
  186. {{form.unit}}
  187. </view>
  188. <view class="pickerText" v-else>
  189. 暂无
  190. </view>
  191. </view>
  192. </uni-col>
  193. </uni-row>
  194. </view>
  195. <view class="desc">
  196. <uni-row>
  197. <uni-col :span="5">
  198. <view class="desc" style="font-size: 25rpx;" v-if="pageType === 'dj'">
  199. 登记数量
  200. </view>
  201. <view class="desc" style="font-size: 25rpx;" v-if="pageType === 'ly'">
  202. 申请数量
  203. </view>
  204. <view class="desc" style="font-size: 25rpx;" v-if="pageType === 'gh'">
  205. 归还数量
  206. </view>
  207. </uni-col>
  208. <uni-col :span="19">
  209. <view>
  210. <u-number-box v-model="form.amount"></u-number-box>
  211. </view>
  212. </uni-col>
  213. </uni-row>
  214. </view>
  215. <view class="desc" v-if="pageType === 'ly'">
  216. <view class="desc" style="font-size: 25rpx;">
  217. 备注:
  218. </view>
  219. <view>
  220. <uni-easyinput type="textarea" primaryColor="#37babd" v-model="form.remark">
  221. </uni-easyinput>
  222. </view>
  223. </view>
  224. </view>
  225. <u-gap height="70" bgColor="#ffffff"></u-gap>
  226. <view class="bottim_view">
  227. <view>
  228. <u-row>
  229. <u-col span="11">
  230. <u-button :disabled="isDisabled" class="btnDoPay" shape="circle" @click="submit"
  231. color="rgb(55,186,189)" text="提交"></u-button>
  232. </u-col>
  233. </u-row>
  234. </view>
  235. </view>
  236. <!-- 物资选择弹窗 -->
  237. <uni-popup ref="goodsPopup" background-color="#fff">
  238. <view style="height: 800rpx;">
  239. <view style="padding: 30rpx;">
  240. <u-search v-model="searchGoodsName" :show-action="false" placeholder="快捷搜索"
  241. @change="getAppGoodsData(typeData.twoType[typeData.twoTypeIndex].id)"></u-search>
  242. </view>
  243. <view style="padding: 5rpx;">
  244. <uni-list v-for="item in goodsData">
  245. <uni-list-item :clickable="true" @click="goodsToSubmiut(item)" :title="item.name" />
  246. </uni-list>
  247. </view>
  248. </view>
  249. </uni-popup>
  250. <!-- 下一步选择人员弹窗 -->
  251. <uni-popup ref="popup" background-color="#fff">
  252. <view style="height: 800rpx;">
  253. <view class="desc">
  254. <uni-row>
  255. <uni-col :span="10">
  256. <view style="font-size: 40rpx;color: rgb(145, 145, 145);">
  257. </view>
  258. </uni-col>
  259. <uni-col :span="11">
  260. <view style="font-size: 40rpx;color: rgb(98, 98, 98);">
  261. 下一步
  262. </view>
  263. </uni-col>
  264. <uni-col :span="3">
  265. <view @click="submitPass" style="font-size: 40rpx;color: rgb(55,186,189);">
  266. 确认
  267. </view>
  268. </uni-col>
  269. </uni-row>
  270. </view>
  271. <view>
  272. <!-- -->
  273. <uni-row>
  274. <uni-col>
  275. <view style="padding: 15rpx 20rpx;">
  276. <uni-data-picker ref="picker" placeholder="请选择" :popup-title="selectTitle"
  277. :localdata="dataTree" v-model="hxForm.candidate" @change="nextApprovalChange">
  278. </uni-data-picker>
  279. </view>
  280. </uni-col>
  281. </uni-row>
  282. </view>
  283. </view>
  284. </uni-popup>
  285. </view>
  286. </template>
  287. <script>
  288. export default {
  289. data() {
  290. return {
  291. isDisabled: false,
  292. selectTitle: '',
  293. form: {
  294. goodsId: '',
  295. goodsName: '',
  296. amount: 1,
  297. unit: '',
  298. remark: ''
  299. },
  300. org_dept_parent_id: '',
  301. searchGoodsName: '',
  302. hxForm: {},
  303. dataTree: [],
  304. index: 0,
  305. defaultDept: '',
  306. reserve_type: [],
  307. goodsData: [],
  308. deptConfig: {
  309. deptDatas: [],
  310. deptIndex: undefined
  311. },
  312. current: 0,
  313. radiolist1: [{
  314. value: '正常'
  315. }, {
  316. value: '异常'
  317. }, {
  318. value: '损坏'
  319. }],
  320. typeData: {
  321. oneTypeIndex: undefined,
  322. oneType: [],
  323. twoTypeIndex: undefined,
  324. twoType: [],
  325. twoTypeDisabled: true
  326. },
  327. outStorageType: {
  328. index: undefined,
  329. data: []
  330. },
  331. accessStorageType: {
  332. index: undefined,
  333. data: []
  334. },
  335. pageType: ''
  336. }
  337. },
  338. onLoad() {
  339. this.pageType = this.$root.$mp.query.pageType
  340. let title = ''
  341. switch (this.pageType) {
  342. case "dj":
  343. title = '物资登记'
  344. this.accessStorageType.data = uni.getStorageSync('access_stroage_type')
  345. this.form.recordType = 1
  346. break
  347. case "ly":
  348. title = '物资领用'
  349. this.outStorageType.data = uni.getStorageSync('out_storage_type')
  350. this.form.recordType = 2
  351. break
  352. case "gh":
  353. title = '物资归还'
  354. this.form.recordType = 3
  355. this.form.applyReason = 5
  356. this.form.remark = '正常'
  357. break
  358. }
  359. uni.setNavigationBarTitle({
  360. title: title
  361. })
  362. //物资一级分类初始化
  363. this.getAppGoodsTypeData('')
  364. //机构信息初始化
  365. this.deptConfig.deptDatas = uni.getStorageSync('deptData')
  366. //申请人初始化
  367. this.form.applyUserName = uni.getStorageSync("userInfo").nickName
  368. //翻译默认部门
  369. let department = uni.getStorageSync('files').department
  370. this.defaultDept = this.$dictTranslation(department, 'deptData', 'dept')
  371. this.form.applyDepartment = department
  372. },
  373. methods: {
  374. openGoodsPopup() {
  375. if (!this.typeData.twoTypeDisabled) {
  376. this.$refs.goodsPopup.open('bottom')
  377. } else {
  378. this.$showModal('请先选择具体分类')
  379. }
  380. },
  381. isTwoTypeShowModal() {
  382. if (this.typeData.twoTypeDisabled) {
  383. this.$showModal('请先选择物资类型')
  384. }
  385. },
  386. change(e) {
  387. console.log(e);
  388. },
  389. radioChange: function(evt) {
  390. this.form.remark = evt.detail.value
  391. },
  392. async submit() {
  393. this.isDisabled = true
  394. setTimeout(() => {
  395. this.isDisabled = false
  396. }, 1000)
  397. if (!this.form.applyDepartment) {
  398. this.isDisabled = false
  399. uni.showModal({
  400. content: '请选择所属部门',
  401. title: '提交失败',
  402. showCancel: false
  403. })
  404. return
  405. }
  406. if (!this.form.goodsName) {
  407. this.isDisabled = false
  408. uni.showModal({
  409. content: '请选择物资',
  410. title: '提交失败',
  411. showCancel: false
  412. })
  413. return
  414. }
  415. if (!this.form.amount) {
  416. this.isDisabled = false
  417. uni.showModal({
  418. content: '请填写数量',
  419. title: '提交失败',
  420. showCancel: false
  421. })
  422. return
  423. }
  424. if (!this.form.applyReason) {
  425. this.isDisabled = false
  426. uni.showModal({
  427. content: '请选择领用类型',
  428. title: '提交失败',
  429. showCancel: false
  430. })
  431. return
  432. }
  433. const {
  434. data: res
  435. } = await this.$httpRequest({
  436. url: '/app/submitApply/rcr',
  437. method: 'post',
  438. data: this.form
  439. });
  440. if (res.code === 200) {
  441. this.dataTree = res.data.tree
  442. this.hxForm.taskId = res.data.taskId
  443. this.$refs.popup.open('bottom')
  444. this.selectTitle = "请选择" + this.dataTree[0].text
  445. this.isDisabled = false
  446. } else {
  447. this.$showModal(res.msg)
  448. }
  449. this.isDisabled = false
  450. },
  451. async submitPass() {
  452. if (!this.hxForm.candidate) {
  453. uni.showModal({
  454. content: '请选择' + this.dataTree[0].text,
  455. title: '提交失败',
  456. showCancel: false,
  457. })
  458. }
  459. const {
  460. data: res
  461. } = await this.$httpRequest({
  462. url: '/app/task/submit/candidate?taskId=' + this.hxForm.taskId +
  463. '&candidate=' + this.hxForm.candidate + '&applyUserName=' + this.hxForm.applyUserName,
  464. method: 'get',
  465. });
  466. if (res.code === 200) {
  467. uni.showModal({
  468. content: '已提交给审批人员',
  469. title: '提交成功',
  470. showCancel: false,
  471. success() {
  472. uni.navigateBack()
  473. }
  474. })
  475. } else {
  476. uni.showModal({
  477. content: res.msg,
  478. title: '提交失败',
  479. showCancel: false,
  480. success() {
  481. uni.navigateBack()
  482. }
  483. })
  484. }
  485. },
  486. nextApprovalChange(e) {
  487. // console.log('onchange:', e.detail.value[1].text);
  488. this.hxForm.applyUserName = e.detail.value[1].text
  489. this.hxForm.candidate = e.detail.value[1].value
  490. },
  491. //获取物资一级/二级类型
  492. async getAppGoodsTypeData(type) {
  493. const {
  494. data: res
  495. } = await this.$httpRequest({
  496. url: '/app/goodsType?type=' + type,
  497. urlType: this.$getUrlType()
  498. });
  499. if (res.code === 200) {
  500. if (type) {
  501. this.typeData.twoType = res.data
  502. this.getAppGoodsData(this.typeData.twoType[0].id)
  503. } else {
  504. this.typeData.oneType = res.data
  505. this.getAppGoodsTypeData(this.typeData.oneType[0].id)
  506. }
  507. }
  508. },
  509. //获取物资信息/查询物资信息
  510. async getAppGoodsData(type) {
  511. const {
  512. data: res
  513. } = await this.$httpRequest({
  514. url: '/app/goodses?type=' + type + '&name=' + this.searchGoodsName,
  515. urlType: this.$getUrlType()
  516. });
  517. if (res.code === 200) {
  518. this.goodsData = res.data
  519. }
  520. },
  521. //选择物资form赋值
  522. goodsToSubmiut(item) {
  523. this.form.goodsName = item.name
  524. this.form.goodsId = item.id
  525. this.form.unit = item.unit
  526. this.$refs.goodsPopup.close()
  527. },
  528. maskClick(e) {},
  529. //选择框赋值区
  530. oneBindPickerChange: function(e) {
  531. this.typeData.oneTypeIndex = e.detail.value
  532. this.getAppGoodsTypeData(this.typeData.oneType[this.typeData.oneTypeIndex].id)
  533. this.typeData.twoTypeIndex = 0
  534. this.typeData.twoTypeDisabled = false
  535. this.form.goodsName = ''
  536. },
  537. twoBindPickerChange: function(e) {
  538. this.typeData.twoTypeIndex = e.detail.value
  539. this.form.goodsName = ''
  540. },
  541. deptBindPickerChange: function(e) {
  542. this.deptConfig.deptIndex = e.detail.value
  543. this.form.applyDepartment = this.deptConfig.deptDatas[this.deptConfig.deptIndex].deptId
  544. },
  545. dictBindPickerChange: function(e) {
  546. this.outStorageType.index = e.detail.value
  547. this.form.applyReason = this.outStorageType.data[this.outStorageType.index].dictValue
  548. },
  549. accessBindPickerChange: function(e) {
  550. this.accessStorageType.index = e.detail.value
  551. this.form.applyReason = this.accessStorageType.data[this.accessStorageType.index].dictValue
  552. }
  553. }
  554. }
  555. </script>
  556. <style lang="scss" scoped>
  557. .desc {
  558. padding: 10rpx 5rpx;
  559. color: #818181;
  560. font-size: 20rpx;
  561. }
  562. .pickerView {
  563. // align-items: flex-end;
  564. padding: 10rpx 20rpx;
  565. border: 1rpx #eeeeee solid;
  566. }
  567. .pickerText {
  568. font-size: 26rpx;
  569. color: #b1b1b1;
  570. }
  571. .bottim_view {
  572. padding: 5px 20px 30px;
  573. position: fixed;
  574. left: 0px;
  575. bottom: 0px;
  576. width: 100%;
  577. height: 40px;
  578. background-color: #ffffff;
  579. }
  580. </style>