application.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. <template>
  2. <view class="container">
  3. <view class="mim-view">
  4. <view class="mim-font-16 bold mim-flex-wrap-left">
  5. <text class="mim-font-16 bold">申请理由</text>
  6. <text class="mim-font-16 bold mimRed">*</text>
  7. </view>
  8. <u-input type="textarea" v-model="form.reason" placeholder='填写申请理由' placeholder-style="color: #BDBDBD;"
  9. height="160" :auto-height='true' :clearable='false' :custom-style="customTestStyle" maxlength="-1"
  10. cursor-spacing="12" />
  11. </view>
  12. <view class="mim-view" v-for="(_, index) in list" :key="index" :class="{margin24 : index > 0 }">
  13. <view class="mim-font-16 bold mim-flex-wrap-space-between">
  14. <view class="mim-font-16 bold mim-flex-wrap-left">
  15. <text class="mim-font-16 bold">协作部门</text>
  16. <text class="mim-font-16 bold mimRed">*</text>
  17. </view>
  18. <view class="mim-flex-wrap-right">
  19. <text class="mim-button mim-font-14" @click="addDepartment">添加</text>
  20. <text v-if="index > 0" class="mim-button mim-button-del mim-font-14" style="margin-left: 24rpx;"
  21. @click="deleteDepartment(index)">删除</text>
  22. </view>
  23. </view>
  24. <view v-if="index == 0" class="mim-font-14 mimRed marginTop">协作部门必须包含本部门</view>
  25. <view class="select">
  26. <u-input type="select" v-model="list[index].deal_department_name" placeholder='请选择协作部门'
  27. placeholder-style="color: #BDBDBD;" height="96" cursor-spacing="12" :clearable='false'
  28. :custom-style="customStyle" @click="selectDepartment(index)" />
  29. <u-image src='@/static/icon/jt.png' class="select_img" width="64rpx" height="64rpx"></u-image>
  30. <u-select v-if="selectVisible[index]" v-model="show" :list="select_list" @confirm="confirmSelect"
  31. :default-value='defaultValue[index]'></u-select>
  32. </view>
  33. <view class="marginTop">
  34. <view class="mim-font-16 bold mim-flex-wrap-left">
  35. <text class="mim-font-16 bold">处理期限(天)</text>
  36. <text class="mim-font-16 bold mimRed">*</text>
  37. </view>
  38. <u-input type="number" v-model="list[index].limit_day" placeholder='请填写处理期限'
  39. placeholder-style="color: #BDBDBD;" height="96" cursor-spacing="12" :clearable='false'
  40. :custom-style="customStyle" @input="validateInput(index)" />
  41. </view>
  42. <view class="marginTop">
  43. <view class="mim-font-16 bold mim-flex-wrap-left">
  44. <text class="mim-font-16 bold">协助内容</text>
  45. <text class="mim-font-16 bold mimRed">*</text>
  46. </view>
  47. <u-input type="textarea" v-model="list[index].body" placeholder='请填写协助内容'
  48. placeholder-style="color: #BDBDBD;" height="160" :auto-height='true' :clearable='false'
  49. :custom-style="customTestStyle" maxlength="-1" cursor-spacing="12" />
  50. </view>
  51. <view class="marginTop" v-if="type == 2">
  52. <view class="mim-font-16 bold mim-flex-wrap-left">
  53. <text class="mim-font-16 bold">处理要求</text>
  54. <text class="mim-font-16 bold mimRed">*</text>
  55. </view>
  56. <u-input type="textarea" v-model="list[index].claim" placeholder='请填写处理要求'
  57. placeholder-style="color: #BDBDBD;" height="160" :auto-height='true' :clearable='false'
  58. :custom-style="customTestStyle" maxlength="-1" cursor-spacing="12" />
  59. </view>
  60. </view>
  61. <view class="mim-view-list"></view>
  62. <view class="mim-view-last"></view>
  63. <view class="mim-foot">
  64. <view class="mim-foot-button mim-flex-wrap" @click="save">
  65. {{saveTitle}}
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. export default {
  72. data() {
  73. return {
  74. customStyle: {
  75. marginTop: '24rpx',
  76. fontSize: '32rpx',
  77. paddingLeft: '24rpx',
  78. background: '#f7f7f7',
  79. borderRadius: '8rpx'
  80. },
  81. customTestStyle: {
  82. "box-sizing": 'border-box',
  83. marginTop: '24rpx',
  84. fontSize: '32rpx',
  85. padding: '32rpx 24rpx',
  86. background: '#f7f7f7',
  87. borderRadius: '8rpx',
  88. },
  89. form: {
  90. id: '',
  91. reason: '',
  92. multiData: []
  93. },
  94. list: [{
  95. deal_department_name: '', //部门名称
  96. department_id: '', //部门id
  97. limit_day: '', //限期
  98. body: '', //处理详情
  99. claim: '' //处理要求
  100. }],
  101. show: false,
  102. selectVisible: [], // 存储每个 u-select 的显示状态
  103. select_list: [],
  104. index: 0,
  105. type: '1', // 1 申请协助 2 审核协助
  106. title: '申请协助',
  107. saveTitle: '确定',
  108. defaultValue: [
  109. [0]
  110. ]
  111. };
  112. },
  113. onLoad(e) {
  114. this.form.id = e.id
  115. this.type = e.type
  116. this.getdepartmentFn()
  117. if (this.type == '1') {
  118. this.title = '申请协助'
  119. this.saveTitle = '确定'
  120. } else {
  121. this.title = '审核协助'
  122. this.saveTitle = '确定审核'
  123. this.commandDetailsFn()
  124. }
  125. },
  126. methods: {
  127. //添加部门
  128. addDepartment() {
  129. this.list.push({
  130. deal_department_name: '',
  131. department_id: '',
  132. limit_day: '',
  133. body: '',
  134. claim: ''
  135. })
  136. this.$u.toast('添加成功!')
  137. },
  138. //删除部门
  139. deleteDepartment(index) {
  140. this.list = this.list.filter((_, index1) => {
  141. return index1 !== index
  142. })
  143. this.$u.toast('删除成功!')
  144. },
  145. //获取部门列表
  146. async getdepartmentFn() {
  147. const res = await this.$u.api.getdepartment({
  148. status: 1,
  149. })
  150. const newArray = res.data.map(item => ({
  151. value: item.id,
  152. label: item.name
  153. }))
  154. this.select_list = newArray
  155. },
  156. //获取详情
  157. async commandDetailsFn() {
  158. const res = await this.$u.api.commandDetails({
  159. id: this.form.id
  160. })
  161. const multiData = res.data.extra.multiData
  162. // this.list = res.data.extra.multiData
  163. multiData.forEach(item => {
  164. const matchingObject = this.select_list.find(obj => obj.value == parseInt(item
  165. .department_id));
  166. if (matchingObject) {
  167. item.deal_department_name = matchingObject.label;
  168. } else {
  169. item.deal_department_name = '';
  170. }
  171. });
  172. this.list = multiData
  173. let index = multiData.map(item => {
  174. let matchingIndex = this.select_list.findIndex(obj => obj.value == parseInt(item
  175. .department_id));
  176. return matchingIndex
  177. });
  178. this.defaultValue = index.map(item => [item]);
  179. if (res.data.extra.reason) {
  180. this.form.reason = res.data.extra.reason
  181. }
  182. },
  183. //确保用户输入非0正整数
  184. validateInput(index) {
  185. const value = this.list[index].limit_day;
  186. const regex = /^[1-9]\d*$/; // 非零正整数的正则表达式
  187. if (!regex.test(value)) {
  188. // 如果输入不符合要求,可以根据需要进行处理,比如清空输入或者修改输入值
  189. // this.list[index].limit_day = ''; // 清空输入
  190. // 或者将输入修改为符合要求的值
  191. this.list[index].limit_day = Math.max(parseInt(value), 1);
  192. }
  193. },
  194. //选择部门
  195. selectDepartment(index) {
  196. this.selectVisible = this.select_list.map((_, i) => i === index);
  197. this.show = true
  198. this.index = index
  199. },
  200. //确定选择
  201. confirmSelect(e) {
  202. this.list[Number(this.index)].department_id = e[0].value
  203. this.list[Number(this.index)].deal_department_name = e[0].label
  204. this.show = false
  205. },
  206. //确定
  207. save() {
  208. if (!this.form.reason) {
  209. this.$u.toast('请填写申请理由!')
  210. return false
  211. }
  212. let arr = []
  213. arr = this.list.filter((item) => {
  214. if (this.type == "2") {
  215. return !item.department_id || !item.body || !item.limit_day || !item.claim
  216. } else {
  217. return !item.department_id || !item.body || !item.limit_day
  218. }
  219. })
  220. if (arr.length > 0) {
  221. this.$u.toast('请将协作部门信息填写完整!')
  222. return false
  223. }
  224. this.form.multiData = this.list
  225. console.log(this.form)
  226. if (this.type == 1) {
  227. this.doHelpFn()
  228. } else {
  229. this.doAuditFn()
  230. }
  231. },
  232. //申请协助
  233. async doHelpFn() {
  234. const res = await this.$u.api.doHelp(this.form)
  235. if (res.status === "success") {
  236. this.$u.toast(res.message)
  237. setTimeout(() => {
  238. this.$u.route({
  239. type: 'navigateBack',
  240. url: '/pages/throughTrain/throughTrainDetails'
  241. });
  242. }, 1500)
  243. }
  244. },
  245. //立即审核
  246. async doAuditFn() {
  247. const res = await this.$u.api.doAudit(this.form)
  248. if (res.status === "success") {
  249. this.$u.toast(res.message)
  250. setTimeout(() => {
  251. this.$u.route({
  252. type: 'navigateBack',
  253. url: '/pages/throughTrain/throughTrainDetails'
  254. });
  255. }, 1500)
  256. }
  257. },
  258. }
  259. }
  260. </script>
  261. <style lang="scss">
  262. page {
  263. background-color: #f7f7f7;
  264. .container {
  265. .mim-view {
  266. margin: 0;
  267. border-radius: 0;
  268. u-input {
  269. /deep/ .u-input__right-icon {
  270. display: none !important;
  271. }
  272. }
  273. .marginTop {
  274. margin-top: 24rpx;
  275. }
  276. .mim-button {
  277. background: rgba(20, 195, 195, 0.15);
  278. border: 2rpx solid #14C3C3;
  279. height: 56rpx;
  280. width: 120rpx;
  281. color: #14C3C3;
  282. }
  283. .mim-button-del {
  284. height: 56rpx;
  285. width: 120rpx;
  286. color: #DE2E27;
  287. background: rgba(222, 46, 39, 0.15);
  288. border: 2rpx solid #DE2E27;
  289. }
  290. .select {
  291. position: relative;
  292. .select_img {
  293. position: absolute;
  294. right: 0;
  295. top: 38rpx;
  296. }
  297. }
  298. }
  299. .margin24 {
  300. margin-top: 24rpx;
  301. }
  302. .mim-view-last {
  303. padding: 56rpx;
  304. background: transparent;
  305. }
  306. .mim-foot {
  307. width: 100%;
  308. height: 136rpx;
  309. position: fixed;
  310. bottom: 0;
  311. left: 0;
  312. background-color: #ffffff;
  313. padding: 20rpx 24rpx;
  314. box-sizing: border-box;
  315. z-index: 9;
  316. &-button {
  317. border-radius: 48rpx;
  318. opacity: 1;
  319. background: #DE2E27;
  320. font-size: 32rpx;
  321. font-weight: normal;
  322. line-height: 32rpx;
  323. letter-spacing: 0px;
  324. color: #FFFFFF;
  325. height: 96rpx;
  326. cursor: pointer;
  327. }
  328. }
  329. }
  330. }
  331. </style>