add.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. <template>
  2. <view class="mx3">
  3. <view class="main-color-bg main-bg-future"></view>
  4. <view class="p3 bg-color-white form-view">
  5. <u-form :model="form" ref="uForm" >
  6. <view class="main-color-text f-size-32 f-weight-6">基本信息</view>
  7. <u-form-item label="设备名称" :label-width="200" prop="sbId" required>
  8. <my-select
  9. :list="sbList"
  10. :disabled="id"
  11. :value-name="'id'"
  12. :label-name="'sbName'"
  13. v-model="form.sbId"
  14. placeholder="请选择设备"
  15. @selected="sbSelect"
  16. />
  17. </u-form-item>
  18. <u-form-item label="日期" :label-width="200" prop="sbId" required>
  19. <u-input
  20. :disabled="true"
  21. v-model="form.fillDate"
  22. placeholder="请输入日期"
  23. @click="showDateTime('fillDate')"/>
  24. <u-picker
  25. mode="time"
  26. :value="fillDateShow"
  27. @cancel="cancelDateTime('fillDate')"
  28. @confirm="confirmDateTime($event,'fillDate',null)"
  29. ></u-picker>
  30. </u-form-item>
  31. <template v-for="natureDict in natureList" >
  32. <view v-show="natureDict.show" :key="natureDict.id" class="main-color-text f-size-32 f-weight-6 mt-2">
  33. {{ natureDict.label }}
  34. </view>
  35. <template v-for="(fillInfo,listIndex ) in fillInfoList" v-if="fillInfo.nature === natureDict.value">
  36. <view :key="fillInfo.infoId" v-if="fillInfo.type === fillInfoTypeValue.FILL_INFO_TYPE_PROJECT_QUANTITY">
  37. <u-form-item
  38. label="作业名称"
  39. :label-width="260">
  40. <my-select
  41. :list="projectQuantityList"
  42. :value-name="'id'"
  43. :label-name="'name'"
  44. v-model="form[fillInfoList[listIndex].infoId]"
  45. @selected="changeProjectQuantity($event,fillInfo)"
  46. placeholder="请选择"
  47. />
  48. </u-form-item>
  49. <u-form-item
  50. label="作业位置"
  51. :label-width="260">
  52. <view class="d-flex">
  53. <u-input style="width: 70rpx;" v-model="form[fillInfoList[listIndex].infoId+'ProjectQuantityS']" type="number" placeholder="起始值" />
  54. <text class="px3">至</text>
  55. <u-input style="width: 70rpx;" v-model="form[fillInfoList[listIndex].infoId+'ProjectQuantityE']" type="number" placeholder="结束值" />
  56. <text v-show="false" class="px3">减</text>
  57. <u-input v-show="false" style="width: 70rpx;" v-model="form[fillInfoList[listIndex].infoId+'ProjectQuantityT']" type="number" placeholder="未工作值" />
  58. <u-input :disabled="true" style="width: 70rpx;" v-model="form[fillInfoList[listIndex].infoId+'SiteUnit']"/>
  59. </view>
  60. </u-form-item>
  61. <u-form-item
  62. label="完成量"
  63. :label-width="260">
  64. <view class="d-flex">
  65. <u-input style="width: 100rpx;" v-model="form[fillInfoList[listIndex].infoId+'ProjectQuantityV']" type="number" placeholder="完成量" />
  66. <u-input :disabled="true" style="width: 70rpx;" v-model="form[fillInfoList[listIndex].infoId+'Unit']"/>
  67. </view>
  68. </u-form-item>
  69. <u-form-item
  70. label="作业备注"
  71. :label-width="260">
  72. <u-input v-model="form[fillInfoList[listIndex].infoId+'RemarkProjectQuantity']" placeholder="请输入" type="textarea" :height="50" />
  73. </u-form-item>
  74. </view>
  75. <view :key="fillInfo.infoId" v-else-if="fillInfo.type === fillInfoTypeValue.FILL_INFO_TYPE_DATE_TIME">
  76. <u-form-item
  77. label="运行开始时间"
  78. :label-width="260">
  79. <u-input
  80. :disabled="true"
  81. v-model="form[fillInfoList[listIndex].infoId+'TimeS']"
  82. placeholder="请输入运行开始时间"
  83. @click="showDateTime('start')"/>
  84. <u-picker
  85. mode="time"
  86. :value="startTimeShow"
  87. @cancel="cancelDateTime('start')"
  88. @confirm="confirmDateTime($event,'start',fillInfoList[listIndex].infoId+'TimeS')"
  89. :params="dateTimeParams"></u-picker>
  90. </u-form-item>
  91. <u-form-item
  92. label="运行结束时间"
  93. :label-width="260">
  94. <u-input
  95. :disabled="true"
  96. v-model="form[fillInfoList[listIndex].infoId+'TimeE']"
  97. placeholder="请输入运行结束时间"
  98. @click="showDateTime('end')"/>
  99. <u-picker
  100. mode="time"
  101. :value="endTimeShow"
  102. @cancel="cancelDateTime('end')"
  103. @confirm="confirmDateTime($event,'end',fillInfoList[listIndex].infoId+'TimeE')"
  104. :params="dateTimeParams"></u-picker>
  105. </u-form-item>
  106. <u-form-item
  107. label="未工作小时"
  108. :label-width="260">
  109. <view class="d-flex">
  110. <u-input
  111. type="number"
  112. style="width: 100rpx;"
  113. v-model="form[fillInfoList[listIndex].infoId+'TimeR']"/>
  114. 小时
  115. </view>
  116. </u-form-item>
  117. </view>
  118. <u-form-item
  119. v-else
  120. :key="fillInfo.infoId"
  121. :label="fillInfo.name"
  122. :label-width="200">
  123. <my-select
  124. v-if="fillInfo.type === fillInfoTypeValue.FILL_INFO_TYPE_XIA_LA"
  125. :list="getSelectOptions(fillInfo)"
  126. :value-name="'id'"
  127. :label-name="'sbName'"
  128. v-model="form[fillInfoList[listIndex].infoId]"
  129. placeholder="请选择"
  130. />
  131. <u-radio-group
  132. v-else-if="fillInfo.type === fillInfoTypeValue.FILL_INFO_TYPE_DAN_XUAN"
  133. v-model="form[fillInfoList[listIndex].infoId]">
  134. <u-radio
  135. v-for="(item,value) in getRadioGroup(fillInfo)"
  136. :key="item.value"
  137. :name="item.value"
  138. >{{ item.label }}
  139. </u-radio>
  140. </u-radio-group>
  141. <template
  142. v-else-if="fillInfo.type === fillInfoTypeValue.FILL_INFO_TYPE_FAN_WEI"
  143. >
  144. <view class="d-flex">
  145. <u-input style="width: 60rpx;" v-model="form[fillInfoList[listIndex].infoId+'Start']" type="number" placeholder="起始值" />
  146. <text class="px3">至</text>
  147. <u-input style="width: 60rpx;" v-model="form[fillInfoList[listIndex].infoId+'End']" type="number" placeholder="结束值" />
  148. <text class="px3">减</text>
  149. <u-input style="width: 60rpx;" v-model="form[fillInfoList[listIndex].infoId+'Eliminate']" type="number" placeholder="未工作值" />
  150. <template v-if="fillInfo.codeValue === fillInfoCodeValue.FILL_INFO_CODE_VALUE_GLS">
  151. KM
  152. </template>
  153. <template v-if="fillInfo.codeValue === fillInfoCodeValue.FILL_INFO_CODE_VALUE_SJS">
  154. 小时
  155. </template>
  156. </view>
  157. </template>
  158. <u-input v-else v-model="form[fillInfoList[listIndex].infoId]" placeholder="请输入" type="textarea" :height="50" />
  159. </u-form-item>
  160. </template>
  161. </template>
  162. </u-form>
  163. <view class="mt-3">
  164. <u-button @click="submit" type="primary" shape="circle">提交</u-button>
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. export default {
  171. props: {
  172. useType: {
  173. type: Number,
  174. default: 1
  175. },
  176. sbId: {
  177. type: String,
  178. default: null
  179. },
  180. id: {
  181. type: String,
  182. default: null
  183. },
  184. projectQuantityList: {
  185. type: Array,
  186. default: () => []
  187. }
  188. },
  189. data() {
  190. return {
  191. form: {
  192. sbId: null
  193. },
  194. dateTimeParams: {
  195. year: true,
  196. month: true,
  197. day: true,
  198. hour: true,
  199. minute: true,
  200. second: true
  201. },
  202. startTimeShow: false,
  203. endTimeShow: false,
  204. fillDateShow: false,
  205. sbInfo: {},
  206. sbList: [],
  207. fillInfoList: [],
  208. natureShowMap: {},
  209. natureList: [],
  210. selectOptionMap: {},
  211. radioGroupMap: {},
  212. fillInfoTypeValue: {},
  213. projectQuantityUnitMap: {},
  214. fillInfoCodeValue: {}
  215. };
  216. },
  217. watch: {
  218. sbId (nVal) {
  219. this.getSbInfo(nVal)
  220. },
  221. id (nVal) {
  222. this.updateModel(nVal)
  223. }
  224. },
  225. created () {
  226. this.fillInfoTypeValue = this.$DictCache.VALUE.FILL_INFO_TYPE;
  227. this.fillInfoCodeValue = this.$DictCache.VALUE.FILL_INFO_CODE_VALUE;
  228. this.projectQuantityUnitMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.FILL_PROJECT_QUANTITY_UNIT)
  229. this.$Http.queryPageByFilter({ filter: 1, pageNum: 1, pageSize: 1000 }).then(res => {
  230. const sbList = res.data.rows;
  231. sbList.forEach(item => {
  232. item.sbName = item.name + '-' + item.no;
  233. })
  234. this.sbList = sbList;
  235. });
  236. // #ifdef H5
  237. this.getSbInfo(this.sbId)
  238. this.updateModel(this.id)
  239. // #endif
  240. },
  241. methods: {
  242. updateModel(id) {
  243. console.log(111, id)
  244. if (!id) {
  245. return
  246. }
  247. if (this.$DictCache.VALUE.FILL_INFO_USE_TYPE.FILL_INFO_USE_TYPE_YUN_XING === this.useType) {
  248. this.$Http.fetchSbRunFill({ id: id }).then(res => {
  249. this.setModel(res.data)
  250. })
  251. } else {
  252. this.$Http.fetchSbInspectionFill({ id: id }).then(res => {
  253. this.setModel(res.data)
  254. })
  255. }
  256. },
  257. getSbInfo(sbId) {
  258. if (sbId) {
  259. this.form.sbId = sbId
  260. this.$Http.fetchSbInfo({ id: sbId }).then(res => {
  261. this.sbSelect(sbId, res.data)
  262. })
  263. }
  264. },
  265. showDateTime(type) {
  266. this.startTimeShow = false
  267. this.endTimeShow = false
  268. this.fillDateShow = false
  269. if (type === 'start') {
  270. this.startTimeShow = true
  271. } else if (type === 'end') {
  272. this.endTimeShow = true
  273. } else {
  274. this.fillDateShow = true
  275. }
  276. },
  277. confirmDateTime(result, type, id) {
  278. console.log(1111, result, id)
  279. if (type === 'start') {
  280. this.form[id] = result.year + '-' + result.month + '-' + result.day +
  281. ' ' + result.hour + ':' + result.minute + ':' + result.second
  282. this.startTimeShow = false
  283. } else if (type === 'end') {
  284. this.form[id] = result.year + '-' + result.month + '-' + result.day +
  285. ' ' + result.hour + ':' + result.minute + ':' + result.second
  286. this.endTimeShow = false
  287. } else {
  288. this.form.fillDate = result.year + '-' + result.month + '-' + result.day
  289. this.fillDateShow = false
  290. }
  291. },
  292. cancelDateTime(type) {
  293. if (type === 'start') {
  294. this.startTimeShow = false
  295. } else if (type === 'end') {
  296. this.endTimeShow = false
  297. } else {
  298. this.fillDateShow = false
  299. }
  300. },
  301. setModel(model) {
  302. this.fillInfoList = [];
  303. this.natureList = [];
  304. this.natureShowMap = {}
  305. const sbInfo = {
  306. 'sbId': model.sbId,
  307. 'fillDate': model.fillDate,
  308. 'fillInfoList': model.fillInfoList
  309. }
  310. const myForm = this.getFillInfoList(model.fillInfoList)
  311. myForm.sbId = model.sbId;
  312. myForm.fillDate = model.fillDate;
  313. const natureList = this.$DictCache.getChildrenList(this.$DictCache.TYPE.FILL_INFO_NATURE)
  314. natureList.forEach(natureItem => {
  315. if (this.natureShowMap[natureItem.value]) {
  316. natureItem.show = true
  317. } else {
  318. natureItem.show = false
  319. }
  320. })
  321. this.form = myForm;
  322. this.sbInfo = sbInfo
  323. this.natureList = natureList;
  324. this.fillInfoList = model.fillInfoList;
  325. },
  326. getFillInfoList(fillInfoList) {
  327. const myForm = {}
  328. fillInfoList.forEach(fillInfo => {
  329. this.natureShowMap[fillInfo.nature] = true
  330. if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_XIA_LA) {
  331. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultValue)) {
  332. myForm[fillInfo.infoId] = fillInfo.resultValue
  333. } else {
  334. myForm[fillInfo.infoId] = this.getSelectOptionDefault(fillInfo)
  335. }
  336. } else if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_DATE_TIME) {
  337. const nowDateTime = this.$u.timeFormat(null, 'yyyy-mm-dd hh:MM:ss');
  338. if (this.$BaseTool.Object.isNotBlank(fillInfo.startTime)) {
  339. myForm[fillInfo.infoId + 'TimeS'] = fillInfo.startTime
  340. } else {
  341. myForm[fillInfo.infoId + 'TimeS'] = nowDateTime
  342. }
  343. if (this.$BaseTool.Object.isNotBlank(fillInfo.endTime)) {
  344. myForm[fillInfo.infoId + 'TimeE'] = fillInfo.endTime
  345. } else {
  346. myForm[fillInfo.infoId + 'TimeE'] = nowDateTime
  347. }
  348. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultEliminate)) {
  349. myForm[fillInfo.infoId + 'TimeR'] = fillInfo.resultEliminate
  350. } else {
  351. myForm[fillInfo.infoId + 'TimeR'] = 0
  352. }
  353. } else if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_DAN_XUAN) {
  354. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultValue)) {
  355. myForm[fillInfo.infoId] = fillInfo.resultValue
  356. } else {
  357. myForm[fillInfo.infoId] = this.getRadioGroupDefault(fillInfo)
  358. }
  359. } else if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_FAN_WEI) {
  360. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultStart)) {
  361. myForm[fillInfo.infoId + 'Start'] = fillInfo.resultStart;
  362. } else {
  363. myForm[fillInfo.infoId + 'Start'] = 0;
  364. }
  365. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultEnd)) {
  366. myForm[fillInfo.infoId + 'End'] = fillInfo.resultEnd;
  367. } else {
  368. myForm[fillInfo.infoId + 'End'] = 0;
  369. }
  370. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultEliminate)) {
  371. myForm[fillInfo.infoId + 'Eliminate'] = fillInfo.resultEliminate;
  372. } else {
  373. myForm[fillInfo.infoId + 'Eliminate'] = 0;
  374. }
  375. } else if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_DECIMAL) {
  376. myForm[fillInfo.infoId] = fillInfo.resultNumber
  377. } else if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_STRING) {
  378. myForm[fillInfo.infoId] = fillInfo.resultDesc
  379. } else if (fillInfo.type === this.fillInfoTypeValue.FILL_INFO_TYPE_PROJECT_QUANTITY) {
  380. myForm[fillInfo.infoId] = this.getProjectQuantityListIdValueDefault(fillInfo).resultDesc
  381. myForm[fillInfo.infoId + 'Unit'] = this.getUnit(fillInfo, 'unit')
  382. myForm[fillInfo.infoId + 'SiteUnit'] = this.getUnit(fillInfo, 'siteUnit')
  383. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultStart)) {
  384. myForm[fillInfo.infoId + 'ProjectQuantityS'] = fillInfo.resultStart;
  385. } else {
  386. myForm[fillInfo.infoId + 'ProjectQuantityS'] = 0;
  387. }
  388. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultEnd)) {
  389. myForm[fillInfo.infoId + 'ProjectQuantityE'] = fillInfo.resultEnd;
  390. } else {
  391. myForm[fillInfo.infoId + 'ProjectQuantityE'] = 0;
  392. }
  393. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultEliminate)) {
  394. myForm[fillInfo.infoId + 'ProjectQuantityT'] = fillInfo.resultEliminate;
  395. } else {
  396. myForm[fillInfo.infoId + 'ProjectQuantityT'] = 0;
  397. }
  398. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultNumber)) {
  399. myForm[fillInfo.infoId + 'ProjectQuantityV'] = fillInfo.resultNumber;
  400. } else {
  401. myForm[fillInfo.infoId + 'ProjectQuantityV'] = 0;
  402. }
  403. if (this.$BaseTool.Object.isNotBlank(fillInfo.remark)) {
  404. myForm[fillInfo.infoId + 'RemarkProjectQuantity'] = fillInfo.remark;
  405. } else {
  406. myForm[fillInfo.infoId + 'RemarkProjectQuantity'] = '';
  407. }
  408. } else {
  409. myForm[fillInfo.infoId] = fillInfo.resultValue
  410. }
  411. })
  412. return myForm
  413. },
  414. sbSelect(value, data) {
  415. // this.$DictCache.VALUE.FILL_INFO_USE_TYPE.FILL_INFO_USE_TYPE_YUN_XING
  416. this.fillInfoList = [];
  417. this.natureList = [];
  418. this.form = { sbId: value };
  419. this.$Http.queryFillExecuteBySbIdUseType({ sbId: value, useType: this.useType }).then(res => {
  420. const fillInfoList = res.data.fillInfoList
  421. const myForm = this.getFillInfoList(res.data.fillInfoList)
  422. myForm.sbId = this.form.sbId;
  423. const nowDateTime = this.$u.timeFormat(null, 'yyyy-mm-dd');
  424. myForm.fillDate = res.data.fillDate ? res.data.fillDate : nowDateTime;
  425. const sbInfo = {
  426. 'sbId': data.id,
  427. 'sbNo': data.no,
  428. 'sbName': data.name,
  429. 'fillDate': res.data.fillDate,
  430. 'fillInfoList': fillInfoList
  431. }
  432. this.natureShowMap = {}
  433. const natureList = this.$DictCache.getChildrenList(this.$DictCache.TYPE.FILL_INFO_NATURE)
  434. natureList.forEach(natureItem => {
  435. if (this.natureShowMap[natureItem.value]) {
  436. natureItem.show = true
  437. } else {
  438. natureItem.show = false
  439. }
  440. })
  441. this.form = myForm;
  442. this.sbInfo = sbInfo;
  443. this.natureList = natureList;
  444. this.fillInfoList = fillInfoList;
  445. })
  446. },
  447. changeProjectQuantity (val, fillInfo) {
  448. const selectList = this.projectQuantityList.filter((item) => { return item.id === val })
  449. this.form[fillInfo.infoId + 'Unit'] = this.projectQuantityUnitMap[selectList[0].unit]
  450. this.form[fillInfo.infoId + 'siteUnit'] = this.projectQuantityUnitMap[selectList[0].siteUnit]
  451. },
  452. getUnit (fillInfo, id) {
  453. const unit = this.getProjectQuantityListIdValueDefault(fillInfo)[id]
  454. if (unit) {
  455. return this.projectQuantityUnitMap[unit]
  456. }
  457. return '无'
  458. },
  459. getProjectQuantityListIdValueDefault (fillInfo) {
  460. let selectItem = {}
  461. let resultStr = null
  462. if (this.$BaseTool.String.isNotBlank(fillInfo.resultDesc)) {
  463. const selectList = this.projectQuantityList.filter((item) => { return item.id === fillInfo.resultDesc })
  464. if (selectList && selectList.length > 0) {
  465. selectItem = selectList[0]
  466. }
  467. resultStr = fillInfo.resultDesc
  468. } else {
  469. if (this.projectQuantityList && this.projectQuantityList.length > 0) {
  470. selectItem = this.projectQuantityList[0]
  471. resultStr = this.projectQuantityList[0].id
  472. }
  473. }
  474. selectItem.resultDesc = resultStr
  475. return selectItem
  476. },
  477. getSelectOptions (fillInfo) {
  478. if (this.$BaseTool.Object.isBlank(this.selectOptionMap[fillInfo.dictType])) {
  479. this.selectOptionMap[fillInfo.dictType] = this.$DictCache.getChildrenList(fillInfo.dictType)
  480. }
  481. return this.selectOptionMap[fillInfo.dictType]
  482. },
  483. getSelectOptionDefault (fillInfo) {
  484. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultValue)) {
  485. return fillInfo.resultValue
  486. }
  487. const options = this.getSelectOptions(fillInfo)
  488. const keys = Object.keys(options)
  489. if (this.$BaseTool.Object.isNotBlank(keys) && keys.length > 0) {
  490. return parseInt(keys[0])
  491. }
  492. return null
  493. },
  494. getRadioGroup (fillInfo) {
  495. if (this.$BaseTool.Object.isBlank(this.radioGroupMap[fillInfo.dictType])) {
  496. this.radioGroupMap[fillInfo.dictType] = this.$DictCache.getChildrenList(fillInfo.dictType)
  497. }
  498. return this.radioGroupMap[fillInfo.dictType]
  499. },
  500. getRadioGroupDefault (fillInfo) {
  501. if (this.$BaseTool.Object.isNotBlank(fillInfo.resultValue)) {
  502. return fillInfo.resultValue
  503. }
  504. const options = this.getRadioGroup(fillInfo)
  505. if (this.$BaseTool.Object.isNotBlank(options) && options.length > 0) {
  506. return options[0].value
  507. }
  508. return null
  509. },
  510. fillInfoSaveValue (sbInfo, values) {
  511. const fillInfoList = sbInfo.fillInfoList
  512. const fillInfoMap = {}
  513. fillInfoList.forEach(item => {
  514. fillInfoMap[item.infoId] = item
  515. })
  516. Object.keys(values).forEach(infoId => {
  517. const startIndex = infoId.indexOf('Start')
  518. const endIndex = infoId.indexOf('End')
  519. const eliminateIndex = infoId.indexOf('Eliminate')
  520. const projectStartIndex = infoId.indexOf('ProjectQuantityS')
  521. const projectEndIndex = infoId.indexOf('ProjectQuantityE')
  522. const projectEliminateIndex = infoId.indexOf('ProjectQuantityT')
  523. const projectResultNumberIndex = infoId.indexOf('ProjectQuantityV')
  524. const remarkProjectQuantityIndex = infoId.indexOf('RemarkProjectQuantity')
  525. const startTimeIndex = infoId.indexOf('TimeS')
  526. const endTimeIndex = infoId.indexOf('TimeE')
  527. const eliminateTimeIndex = infoId.indexOf('TimeR')
  528. if (startIndex > 0) {
  529. const realInfoId = infoId.substring(0, startIndex)
  530. fillInfoMap[realInfoId].resultStart = values[infoId]
  531. } else if (endIndex > 0) {
  532. const realInfoId = infoId.substring(0, endIndex)
  533. fillInfoMap[realInfoId].resultEnd = values[infoId]
  534. } else if (eliminateIndex > 0) {
  535. const realInfoId = infoId.substring(0, eliminateIndex)
  536. fillInfoMap[realInfoId].resultEliminate = values[infoId]
  537. } else if (startTimeIndex > 0) {
  538. const realInfoId = infoId.substring(0, startTimeIndex)
  539. fillInfoMap[realInfoId].startTime = values[infoId]
  540. } else if (endTimeIndex > 0) {
  541. const realInfoId = infoId.substring(0, endTimeIndex)
  542. fillInfoMap[realInfoId].endTime = values[infoId]
  543. } else if (eliminateTimeIndex > 0) {
  544. const realInfoId = infoId.substring(0, eliminateTimeIndex)
  545. fillInfoMap[realInfoId].resultEliminate = values[infoId]
  546. } else if (projectStartIndex > 0) {
  547. const realInfoId = infoId.substring(0, projectStartIndex)
  548. fillInfoMap[realInfoId].resultStart = values[infoId]
  549. } else if (projectEndIndex > 0) {
  550. const realInfoId = infoId.substring(0, projectEndIndex)
  551. fillInfoMap[realInfoId].resultEnd = values[infoId]
  552. } else if (projectEliminateIndex > 0) {
  553. const realInfoId = infoId.substring(0, projectEliminateIndex)
  554. fillInfoMap[realInfoId].resultEliminate = values[infoId]
  555. } else if (projectResultNumberIndex > 0) {
  556. const realInfoId = infoId.substring(0, projectResultNumberIndex)
  557. fillInfoMap[realInfoId].resultNumber = values[infoId]
  558. } else if (remarkProjectQuantityIndex > 0) {
  559. const realInfoId = infoId.substring(0, remarkProjectQuantityIndex)
  560. fillInfoMap[realInfoId].remark = values[infoId]
  561. } else {
  562. const fillInfo = fillInfoMap[infoId]
  563. if (fillInfo != null) {
  564. if (fillInfo.type === this.$DictCache.VALUE.FILL_INFO_TYPE.FILL_INFO_TYPE_INT) {
  565. fillInfoMap[infoId].resultValue = values[infoId]
  566. } else if (fillInfo.type === this.$DictCache.VALUE.FILL_INFO_TYPE.FILL_INFO_TYPE_DECIMAL) {
  567. fillInfoMap[infoId].resultNumber = values[infoId]
  568. } else if (fillInfo.type === this.$DictCache.VALUE.FILL_INFO_TYPE.FILL_INFO_TYPE_STRING) {
  569. fillInfoMap[infoId].resultDesc = values[infoId]
  570. } else if (fillInfo.type === this.$DictCache.VALUE.FILL_INFO_TYPE.FILL_INFO_TYPE_XIA_LA) {
  571. fillInfoMap[infoId].resultValue = values[infoId]
  572. } else if (fillInfo.type === this.$DictCache.VALUE.FILL_INFO_TYPE.FILL_INFO_TYPE_DAN_XUAN) {
  573. fillInfoMap[infoId].resultValue = values[infoId]
  574. } else if (fillInfo.type === this.$DictCache.VALUE.FILL_INFO_TYPE.FILL_INFO_TYPE_PROJECT_QUANTITY) {
  575. console.log(555555, values[infoId])
  576. fillInfoMap[infoId].resultDesc = values[infoId]
  577. } else {
  578. }
  579. }
  580. }
  581. })
  582. const resultInfoList = []
  583. Object.values(fillInfoMap).forEach(fillInfo => {
  584. resultInfoList.push(fillInfo)
  585. })
  586. return resultInfoList
  587. },
  588. submit() {
  589. console.log(this.form);
  590. if (Object.keys(this.form).length <= 1) {
  591. uni.showToast({ icon: 'none', title: '请填写填报项' });
  592. return
  593. }
  594. this.sbInfo.fillInfoList = this.fillInfoSaveValue(this.sbInfo, this.form)
  595. this.sbInfo.fillDate = this.form.fillDate
  596. const fill = {
  597. id: this.id,
  598. sbId: this.form.sbId,
  599. fillDate: this.form.fillDate
  600. }
  601. fill.fillInfoList = this.sbInfo.fillInfoList
  602. if (this.$DictCache.VALUE.FILL_INFO_USE_TYPE.FILL_INFO_USE_TYPE_YUN_XING === this.useType) {
  603. if (this.id) {
  604. this.$Http.updateSbRunFill(fill).then(() => {
  605. uni.redirectTo({
  606. url: '/pages/running/running'
  607. });
  608. }).catch(() => {
  609. })
  610. } else {
  611. this.$Http.addSbRunFills([this.sbInfo])
  612. .then(() => {
  613. uni.redirectTo({
  614. url: '/pages/running/running'
  615. });
  616. }).catch(() => {
  617. })
  618. }
  619. } else if (this.$DictCache.VALUE.FILL_INFO_USE_TYPE.FILL_INFO_USE_TYPE_XUN_JIAN === this.useType) {
  620. if (this.id) {
  621. this.$Http.updateSbInspectionFill(fill).then(() => {
  622. uni.redirectTo({
  623. url: '/pages/inspection/inspection'
  624. });
  625. }).catch(() => {
  626. })
  627. } else {
  628. this.$Http.addSbInspectionFill([this.sbInfo])
  629. .then(() => {
  630. uni.redirectTo({
  631. url: '/pages/inspection/inspection'
  632. });
  633. }).catch(() => {
  634. })
  635. }
  636. }
  637. }
  638. }
  639. };
  640. </script>
  641. <style></style>