You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

395 lines
15 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-select
  5. @input="setValue('Acc_GoodsDemage.Dormitory', $event)"
  6. :value="getValue('Acc_GoodsDemage.Dormitory')"
  7. :disabled="!edit"
  8. :range="dataSource.Acc_GoodsDemage.Dormitory"
  9. @change="DormitoryChange"
  10. title="宿舍楼"
  11. required
  12. />
  13. <l-select
  14. @input="setValue('Acc_GoodsDemage.Unit', $event)"
  15. :value="getValue('Acc_GoodsDemage.Unit')"
  16. :disabled="!edit"
  17. :range="dataSource.Acc_GoodsDemage.Unit"
  18. @change="UnitChange"
  19. title="单元"
  20. required
  21. />
  22. <l-select
  23. @input="setValue('Acc_GoodsDemage.Floor', $event)"
  24. :value="getValue('Acc_GoodsDemage.Floor')"
  25. :disabled="!edit"
  26. :range="dataSource.Acc_GoodsDemage.Floor"
  27. @change="FloorChange"
  28. title="楼层"
  29. required
  30. />
  31. <l-select
  32. @input="setValue('Acc_GoodsDemage.RId', $event)"
  33. :value="getValue('Acc_GoodsDemage.RId')"
  34. :disabled="!edit"
  35. :range="dataSource.Acc_GoodsDemage.RId"
  36. title="宿舍"
  37. required
  38. />
  39. <l-select
  40. @input="setValue('Acc_GoodsDemage.DeptNo', $event)"
  41. :value="getValue('Acc_GoodsDemage.DeptNo')"
  42. :disabled="!edit"
  43. :range="dataSource.Acc_GoodsDemage.DeptNo"
  44. @change="DeptNoChange"
  45. title="专业部"
  46. required
  47. />
  48. <l-select
  49. @input="setValue('Acc_GoodsDemage.MajorNo', $event)"
  50. :value="getValue('Acc_GoodsDemage.MajorNo')"
  51. :disabled="!edit"
  52. :range="dataSource.Acc_GoodsDemage.MajorNo"
  53. @change="MajorNoChange"
  54. title="专业"
  55. required
  56. />
  57. <l-select
  58. @input="setValue('Acc_GoodsDemage.ClassNo', $event)"
  59. :value="getValue('Acc_GoodsDemage.ClassNo')"
  60. :disabled="!edit"
  61. :range="dataSource.Acc_GoodsDemage.ClassNo"
  62. title="班级"
  63. required
  64. />
  65. <l-textarea
  66. @input="setValue('Acc_GoodsDemage.DamageDescribe', $event)"
  67. :value="getValue('Acc_GoodsDemage.DamageDescribe')"
  68. :readonly="!edit"
  69. title="损坏描述"
  70. required
  71. />
  72. <!-- 附件上传 -->
  73. <l-input
  74. @input="setValue('Acc_GoodsDemage.Files', $event)"
  75. :value="getValue('Acc_GoodsDemage.Files')"
  76. disabled="disabled"
  77. v-show="false"
  78. title="附件值"
  79. />
  80. <uploadFile :number="5" :folderId="folderId" :value="fileList" :readonly="!edit" :title="fileTitle" :required="false"></uploadFile>
  81. </view>
  82. <view v-if="ready" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  83. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  84. 提交保存
  85. </l-button>
  86. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  87. 取消编辑
  88. </l-button>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. /*
  94. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  95. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  96. * 创建人:超级管理员
  97. * 日 期:2022-09-19 09:37
  98. * 描 述:宿舍物品损坏上报
  99. */
  100. /**
  101. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  102. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  103. * { "path": "pages/LogisticsManagement/Acc_GoodsDemage/single", "style": { "navigationBarTitleText": "表单详情页" } }
  104. *
  105. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  106. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  107. */
  108. import get from 'lodash/get'
  109. import set from 'lodash/set'
  110. import moment from 'moment'
  111. import customPageMixins from '@/common/custompage.js'
  112. import uploadFile from '@/components/upload-file2.vue'
  113. export default {
  114. mixins: [customPageMixins],
  115. components:{
  116. uploadFile,
  117. },
  118. data() {
  119. return {
  120. // 页面相关参数
  121. id: null,
  122. mode: null,
  123. edit: null,
  124. ready: false,
  125. fileList:[],//附件列表
  126. folderId:null,//附件随机文件夹id
  127. fileTitle:'附件上传',//附件label值
  128. // 表单数据
  129. current: {},
  130. origin: {},
  131. // 表单项数据结构
  132. scheme: {
  133. Acc_GoodsDemage: {
  134. DeptNo: { type: 'select', title: '专业部', dataSource: '1', dataSourceId: 'CdDeptInfo,deptname,deptno', verify: 'NotNull' },
  135. MajorNo: { type: 'select', title: '专业', dataSource: '1', dataSourceId: 'CdMajorInfo,majorname,majorno', verify: 'NotNull' },
  136. ClassNo: { type: 'select', title: '班级', dataSource: '1', dataSourceId: 'bjsj,classname,classno', verify: 'NotNull' },
  137. Dormitory: { type: 'select', title: '宿舍楼', dataSource: '1', dataSourceId: 'Acc_DormitoryData,name,id', verify: 'NotNull' },
  138. Unit: { type: 'select', title: '单元', dataSource: '1', dataSourceId: 'Acc_UnitData,name,id', verify: 'NotNull' },
  139. Floor: { type: 'select', title: '楼层', dataSource: '1', dataSourceId: 'Acc_FloorData,name,id' , verify: 'NotNull' },
  140. RId: { type: 'select', title: '宿舍', dataSource: '1', dataSourceId: 'Acc_RoomData,name,id' , verify: 'NotNull'},
  141. DamageDescribe: { type: 'textarea', title: '损坏描述' , verify: 'NotNull'},
  142. Files: { type: "text", title: "附件上传" },
  143. },
  144. },
  145. // 数据源
  146. dataSource: {
  147. Acc_GoodsDemage: {
  148. DeptNo: [],
  149. MajorNo: [],
  150. ClassNo: [],
  151. Dormitory: [],
  152. Unit: [],
  153. Floor: [],
  154. RId: [],
  155. },
  156. }
  157. }
  158. },
  159. async onLoad({ type, id }) {
  160. await this.init(type, id)
  161. },
  162. methods: {
  163. // 页面初始化
  164. async init(type, id) {
  165. this.folderId=this.GUID();
  166. // console.log('附件随机文件夹id:'+this.folderId);
  167. this.LOADING('加载数据中...')
  168. this.id = id
  169. this.mode = type
  170. this.edit = ['create', 'edit'].includes(this.mode)
  171. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  172. await Promise.all([
  173. this.FETCH_DATASOURCE('CdDeptInfo').then(result => {
  174. this.dataSource.Acc_GoodsDemage.DeptNo = result.data.sort((a,b)=>{return a.deptsort-b.deptsort}).map(t => ({ text: t.deptname, value: t.deptno }))
  175. }),
  176. this.FETCH_DATASOURCE('CdMajorInfo').then(result => {
  177. this.dataSource.Acc_GoodsDemage.MajorNo = result.data.sort((a,b)=>{return a.majorno-b.majorno}).map(t => ({ text: t.majorname, value: t.majorno }))
  178. }),
  179. this.FETCH_DATASOURCE('bjsj').then(result => {
  180. this.dataSource.Acc_GoodsDemage.ClassNo = result.data.sort((a,b)=>{return b.classno-a.classno}).map(t => ({ text: t.classname, value: t.classno }))
  181. }),
  182. this.FETCH_DATASOURCE('Acc_DormitoryData').then(result => {
  183. this.dataSource.Acc_GoodsDemage.Dormitory = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  184. }),
  185. this.FETCH_DATASOURCE('Acc_UnitData').then(result => {
  186. this.dataSource.Acc_GoodsDemage.Unit = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  187. }),
  188. this.FETCH_DATASOURCE('Acc_FloorData').then(result => {
  189. this.dataSource.Acc_GoodsDemage.Floor = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  190. }),
  191. this.FETCH_DATASOURCE('Acc_RoomData').then(result => {
  192. this.dataSource.Acc_GoodsDemage.RId = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  193. }),
  194. () => {}
  195. ])
  196. await this.fetchForm()
  197. this.ready = true
  198. this.HIDE_LOADING()
  199. },
  200. // 加载表单数据
  201. async fetchForm() {
  202. if (this.mode === 'create') {
  203. this.origin = await this.getDefaultForm()
  204. } else {
  205. const result = await this.HTTP_GET('learun/adms/LogisticsManagement/Acc_GoodsDemage/form', this.id)
  206. this.origin = await this.formatFormData(result)
  207. }
  208. this.current = this.COPY(this.origin)
  209. //加载附件值数据
  210. // console.log('附件值赋值前:'+this.getValue('Acc_GoodsDemage.Files'));
  211. if (this.getValue('Acc_GoodsDemage.Files') == ""||this.getValue('Acc_GoodsDemage.Files') == undefined ||this.getValue('Acc_GoodsDemage.Files') == null) {
  212. this.setValue('Acc_GoodsDemage.Files',this.folderId);
  213. // console.log('附件值赋值后:'+this.getValue('Acc_GoodsDemage.Files'));
  214. }else{
  215. this.folderId=this.getValue('Acc_GoodsDemage.Files');
  216. // console.log('文件夹id赋值后:'+this.folderId);
  217. //请求‘获取附件列表’接口
  218. this.fileList = await this.FETCH_FILEList(this.getValue('Acc_GoodsDemage.Files'));
  219. }
  220. // console.log('origin:'+JSON.stringify(this.origin) )
  221. // console.log('current:'+JSON.stringify(this.current))
  222. },
  223. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  224. async action(type) {
  225. switch (type) {
  226. case 'edit':
  227. this.edit = true
  228. break
  229. case 'reset':
  230. this.current = this.COPY(this.origin)
  231. this.edit = false
  232. break
  233. case 'save':
  234. const verifyResult = this.verifyForm()
  235. if (verifyResult.length > 0) {
  236. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  237. return
  238. }
  239. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  240. return
  241. }
  242. this.LOADING('正在提交...')
  243. const postData = await this.getPostData(this.id)
  244. // console.log('页面提交数据:'+JSON.stringify(postData));
  245. this.HTTP_POST('learun/adms/LogisticsManagement/Acc_GoodsDemage/save', postData, '表单提交保存失败').then(success => {
  246. this.HIDE_LOADING()
  247. if (!success) {
  248. return
  249. }
  250. this.EMIT('LogisticsManagementAcc_GoodsDemage-list-change')
  251. this.NAV_BACK()
  252. this.TOAST('提交保存成功')
  253. })
  254. break
  255. case 'delete':
  256. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  257. return
  258. }
  259. this.LOADING('提交删除中...')
  260. this.HTTP_POST('learun/adms/LogisticsManagement/Acc_GoodsDemage/delete', this.id, '删除失败').then(success => {
  261. this.HIDE_LOADING()
  262. if (!success) {
  263. return
  264. }
  265. this.EMIT('LogisticsManagementAcc_GoodsDemage-list-change')
  266. this.NAV_BACK()
  267. this.this.TOAST('删除成功', 'success')
  268. })
  269. break
  270. default: break
  271. }
  272. },
  273. // 获取表单值
  274. getValue(path) {
  275. return get(this.current, path)
  276. },
  277. // 设置表单值
  278. setValue(path, val) {
  279. set(this.current, path, val)
  280. },
  281. //多条件查询:宿舍楼改变事件
  282. async DormitoryChange(){
  283. if (this.getValue('Acc_GoodsDemage.Dormitory') != null && this.getValue('Acc_GoodsDemage.Dormitory') !=undefined && this.getValue('Acc_GoodsDemage.Dormitory') != "") {
  284. this.FETCH_DATASOURCE('Acc_UnitData').then(result => {
  285. this.dataSource.Acc_GoodsDemage.Unit = result.data.sort((a,b)=>{return a.dno-b.dno}).filter(t=>t.parentid===this.getValue('Acc_GoodsDemage.Dormitory') ).map(t => ({ text: t.name, value: t.id }))
  286. })
  287. }else{
  288. this.FETCH_DATASOURCE('Acc_UnitData').then(result => {
  289. this.dataSource.Acc_GoodsDemage.Unit = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  290. })
  291. }
  292. this.setValue('Acc_GoodsDemage.Unit','');
  293. this.setValue('Acc_GoodsDemage.Floor','');
  294. this.setValue('Acc_GoodsDemage.RId','');
  295. },//多条件查询:单元改变事件
  296. async UnitChange(){
  297. if (this.getValue('Acc_GoodsDemage.Unit') != null && this.getValue('Acc_GoodsDemage.Unit')!=undefined && this.getValue('Acc_GoodsDemage.Unit')!= "") {
  298. this.FETCH_DATASOURCE('Acc_FloorData').then(result => {
  299. this.dataSource.Acc_GoodsDemage.Floor = result.data.sort((a,b)=>{return a.dno-b.dno}).filter(t=>t.parentid===this.getValue('Acc_GoodsDemage.Unit')).map(t => ({ text: t.name, value: t.id }))
  300. })
  301. }else{
  302. this.FETCH_DATASOURCE('Acc_FloorData').then(result => {
  303. this.dataSource.Acc_GoodsDemage.Floor = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  304. })
  305. }
  306. this.setValue('Acc_GoodsDemage.Floor','');
  307. this.setValue('Acc_GoodsDemage.RId','');
  308. },
  309. //多条件查询:楼层改变事件
  310. async FloorChange(){
  311. if (this.getValue('Acc_GoodsDemage.Floor') != null && this.getValue('Acc_GoodsDemage.Floor')!=undefined && this.getValue('Acc_GoodsDemage.Floor') != "") {
  312. this.FETCH_DATASOURCE('Acc_RoomData').then(result => {
  313. this.dataSource.Acc_GoodsDemage.RId = result.data.sort((a,b)=>{return a.dno-b.dno}).filter(t=>t.parentid===this.getValue('Acc_GoodsDemage.Floor')).map(t => ({ text: t.name, value: t.id }))
  314. })
  315. }else{
  316. this.FETCH_DATASOURCE('Acc_RoomData').then(result => {
  317. this.dataSource.Acc_GoodsDemage.RId = result.data.sort((a,b)=>{return a.parentid-b.parentid}).map(t => ({ text: t.name, value: t.id }))
  318. })
  319. }
  320. this.setValue('Acc_GoodsDemage.RId','');
  321. },
  322. //多条件查询:专业部改变事件
  323. async DeptNoChange(){
  324. if (this.getValue('Acc_GoodsDemage.DeptNo') != null && this.getValue('Acc_GoodsDemage.DeptNo')!=undefined && this.getValue('Acc_GoodsDemage.DeptNo') != "") {
  325. this.FETCH_DATASOURCE('CdMajorInfo').then(result => {
  326. this.dataSource.Acc_GoodsDemage.MajorNo = result.data.sort((a,b)=>{return a.majorno-b.majorno}).filter(t=>t.deptno===this.getValue('Acc_GoodsDemage.DeptNo')).map(t => ({ text: t.majorname, value: t.majorno }))
  327. })
  328. }else{
  329. this.FETCH_DATASOURCE('CdMajorInfo').then(result => {
  330. this.dataSource.Acc_GoodsDemage.MajorNo = result.data.sort((a,b)=>{return a.majorno-b.majorno}).map(t => ({ text: t.majorname, value: t.majorno }))
  331. })
  332. }
  333. this.setValue('Acc_GoodsDemage.MajorNo','');
  334. this.setValue('Acc_GoodsDemage.ClassNo','');
  335. },
  336. //多条件查询:专业改变事件
  337. async MajorNoChange(){
  338. if (this.getValue('Acc_GoodsDemage.MajorNo') != null && this.getValue('Acc_GoodsDemage.MajorNo')!=undefined && this.getValue('Acc_GoodsDemage.MajorNo') != "") {
  339. this.FETCH_DATASOURCE('bjsj').then(result => {
  340. this.dataSource.Acc_GoodsDemage.ClassNo = result.data.sort((a,b)=>{return b.classno-a.classno}).filter(t=>t.majorno===this.getValue('Acc_GoodsDemage.MajorNo')).map(t => ({ text: t.classname, value: t.classno }))
  341. })
  342. }else{
  343. this.FETCH_DATASOURCE('bjsj').then(result => {
  344. this.dataSource.Acc_GoodsDemage.ClassNo = result.data.sort((a,b)=>{return b.classno-a.classno}).map(t => ({ text: t.classname, value: t.classno }))
  345. })
  346. }
  347. this.setValue('Acc_GoodsDemage.ClassNo','');
  348. },
  349. }
  350. }
  351. </script>