safeStorageInspectEdit.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="content">
  3. <u--form ref="editForm" :model="form" :rules="rules" labelPosition="left" class="form">
  4. <u-row :customStyle="rowStyle">
  5. <u-col :span="4">
  6. <u-form-item label="库点名称" prop="orgName" label-width="100" class="item" required>
  7. <u-input v-model="form.orgName" readonly></u-input>
  8. </u-form-item>
  9. </u-col>
  10. <u-col :span="4">
  11. <u-form-item label="仓房名称" prop="basicStorehouseId" label-width="100" class="item" required>
  12. <simple-select v-model="form.basicStorehouseId" load-type="local" :data="houseOptions"
  13. :readonly="readonly" @on-change="houseChanged" />
  14. </u-form-item>
  15. </u-col>
  16. <u-col :span="4">
  17. <u-form-item label="货位名称" prop="warehouseId" label-width="100" class="item" required>
  18. <simple-select v-model="form.warehouseId" load-type="local" :data="wareOptions"
  19. :readonly="readonly" @on-change="wareChanged" />
  20. </u-form-item>
  21. </u-col>
  22. </u-row>
  23. <u-row :customStyle="rowStyle">
  24. <u-col :span="4">
  25. <u-form-item label="粮食种类" prop="grainVarietyName" label-width="100" class="item" required>
  26. <u-input v-model="form.grainVarietyName" readonly></u-input>
  27. </u-form-item>
  28. </u-col>
  29. <u-col :span="4">
  30. <u-form-item label="粮食等级" prop="grainGradeName" label-width="100" class="item" required>
  31. <u-input v-model="form.grainGradeName" readonly></u-input>
  32. </u-form-item>
  33. </u-col>
  34. <u-col :span="4">
  35. <u-form-item label="收获年度" prop="harvestYear" label-width="100" class="item" required>
  36. <year-select v-model.number="form.harvestYear" :readonly="readonly"></year-select>
  37. </u-form-item>
  38. </u-col>
  39. </u-row>
  40. <u-row :customStyle="rowStyle">
  41. <u-col :span="4">
  42. <u-form-item label="检查人" prop="inspector" label-width="100" class="item" required>
  43. <u-input v-model="form.inspector" :readonly="readonly"></u-input>
  44. </u-form-item>
  45. </u-col>
  46. <u-col :span="4">
  47. <u-form-item label="保管员" prop="keeper" label-width="100" class="item" required>
  48. <u-input v-model="form.keeper" :readonly="readonly"></u-input>
  49. </u-form-item>
  50. </u-col>
  51. <u-col :span="4">
  52. <u-form-item label="粮温℃" prop="grainTemperature" label-width="100" class="item">
  53. <u-input v-model="form.grainTemperature" :readonly="readonly"></u-input>
  54. </u-form-item>
  55. </u-col>
  56. </u-row>
  57. <u-row :customStyle="rowStyle">
  58. <u-col :span="4">
  59. <u-form-item label="仓温℃" prop="storeroomTemperature" label-width="100" class="item">
  60. <u-input v-model="form.storeroomTemperature" :readonly="readonly"></u-input>
  61. </u-form-item>
  62. </u-col>
  63. <u-col :span="4">
  64. <u-form-item label="气温℃" prop="ambientTemperature" label-width="100" class="item">
  65. <u-input v-model="form.ambientTemperature" :readonly="readonly"></u-input>
  66. </u-form-item>
  67. </u-col>
  68. <u-col :span="4">
  69. <u-form-item label="仓内湿%" prop="storeroomHumidity" label-width="100" class="item">
  70. <u-input v-model="form.storeroomHumidity" :readonly="readonly"></u-input>
  71. </u-form-item>
  72. </u-col>
  73. </u-row>
  74. <u-row :customStyle="rowStyle">
  75. <u-col :span="4">
  76. <u-form-item label="仓外湿%" prop="ambientHumidity" label-width="100" class="item">
  77. <u-input v-model="form.ambientHumidity" :readonly="readonly"></u-input>
  78. </u-form-item>
  79. </u-col>
  80. <u-col :span="4">
  81. <u-form-item label="检查日期" prop="inspectionDate" label-width="100" class="item">
  82. <uni-datetime-picker type="datetime" v-model="form.inspectionDate" :disabled="readonly" />
  83. </u-form-item>
  84. </u-col>
  85. </u-row>
  86. <u-divider text="日常检查"></u-divider>
  87. <u-row :customStyle="rowStyle">
  88. <u-col :span="4">
  89. <u-form-item label="鼠雀检查" prop="rodentCheck" label-width="100" class="item">
  90. <simple-select v-model="form.rodentCheck" data="OPT2" load-type="static" :readonly="readonly" />
  91. </u-form-item>
  92. </u-col>
  93. <u-col :span="4">
  94. <u-form-item label="是否结露" prop="isCondensation" label-width="100" class="item">
  95. <simple-select v-model="form.isCondensation" data="OPT2" load-type="static"
  96. :readonly="readonly" />
  97. </u-form-item>
  98. </u-col>
  99. <u-col :span="4">
  100. <u-form-item label="粮食霉变情况" prop="moldCondition" label-width="100" class="item">
  101. <simple-select v-model="form.moldCondition" data="OPT2" load-type="static"
  102. :readonly="readonly" />
  103. </u-form-item>
  104. </u-col>
  105. </u-row>
  106. <u-row :customStyle="rowStyle">
  107. <u-col :span="4">
  108. <u-form-item label="是否板结" prop="isLump" label-width="100" class="item">
  109. <simple-select v-model="form.isLump" data="OPT2" load-type="static" :readonly="readonly" />
  110. </u-form-item>
  111. </u-col>
  112. <u-col :span="4">
  113. <u-form-item label="发热现象" prop="heatingPhenomenon" label-width="100" class="item">
  114. <u-input v-model="form.heatingPhenomenon" :readonly="readonly"></u-input>
  115. </u-form-item>
  116. </u-col>
  117. <u-col :span="4">
  118. <u-form-item label="仓房有无渗漏" prop="isLeakage" label-width="100" class="item">
  119. <simple-select v-model="form.isLeakage" data="OPT2" load-type="static" :readonly="readonly" />
  120. </u-form-item>
  121. </u-col>
  122. </u-row>
  123. <u-row :customStyle="rowStyle">
  124. <u-col :span="4">
  125. <u-form-item label="仓房是否返潮" prop="isReturnDamp" label-width="100" class="item">
  126. <simple-select v-model="form.isReturnDamp" data="OPT2" load-type="static"
  127. :readonly="readonly" />
  128. </u-form-item>
  129. </u-col>
  130. <u-col :span="4">
  131. <u-form-item label="是否有害虫" prop="isPest" label-width="100" class="item">
  132. <simple-select v-model="form.isPest" data="OPT2" load-type="static" :readonly="readonly" />
  133. </u-form-item>
  134. </u-col>
  135. </u-row>
  136. <u-divider text="拍照上传"></u-divider>
  137. <simple-upload :file-list="uploadFiles" :readonly="readonly" @on-change="uploadChanged" />
  138. </u--form>
  139. <view class="buttons">
  140. <u-button v-if="! readonly" text="保存" @tap="save" type="primary" class="btn"></u-button>
  141. <u-button text="取消" @tap="back" class="btn"></u-button>
  142. </view>
  143. </view>
  144. </template>
  145. <script>
  146. import simpleEdit from '@/components/simple-edit/index.js'
  147. import simpleSelect from '@/components/simpleSelect.vue'
  148. import yearSelect from '@/components/yearSelect.vue'
  149. import {
  150. getDetail,
  151. update,
  152. getGrain
  153. } from '@/api/safeStorageInspect.js'
  154. import {
  155. defaultRequired,
  156. simpleRequired
  157. } from '@/utils/rules'
  158. import {
  159. deleteField,
  160. isNull,
  161. parseField2SomeType
  162. } from '@/utils/tools'
  163. import houseOptions from '@/components/plugins/houseOptions'
  164. import wareOptions from '@/components/plugins/wareOptions'
  165. import simpleUpload from '@/components/simpleUpload.vue'
  166. export default {
  167. mixins: [simpleEdit, houseOptions, wareOptions],
  168. components: {
  169. simpleSelect,
  170. simpleUpload, yearSelect
  171. },
  172. data() {
  173. return {
  174. listUrl: '/pages/safeStorageInspect/safeStorageInspect',
  175. uploadFiles: [],
  176. defaultForm: {
  177. orgName: null,
  178. basicStorehouseId: null,
  179. warehouseId: null,
  180. grainVarietyName: null,
  181. grainGradeName: null,
  182. harvestYear: null,
  183. inspector: null,
  184. keeper: null,
  185. },
  186. rules: {
  187. orgName: defaultRequired,
  188. basicStorehouseId: defaultRequired,
  189. warehouseId: defaultRequired,
  190. grainVarietyName: defaultRequired,
  191. grainGradeName: defaultRequired,
  192. harvestYear: defaultRequired,
  193. inspector: defaultRequired,
  194. keeper: defaultRequired,
  195. }
  196. }
  197. },
  198. methods: {
  199. setUp() {
  200. this.addAfterHook(() => {
  201. return this.getHouseOptions(this.form.orgId)
  202. })
  203. this.addAfterHook(() => {
  204. return this.getGrainInfo(this.form.basicStorehouseId, this.form.warehouseId, this.form.orgId)
  205. })
  206. this.addAfterHook(() => {
  207. console.log('edit data', this.editData, this.form);
  208. const files = this.form.images || ''
  209. if (files) {
  210. this.uploadFiles = files.split(',').map(d => {
  211. return {
  212. url: d,
  213. }
  214. })
  215. } else {
  216. this.uploadFiles = []
  217. }
  218. return this.getWareOptions(this.form.basicStorehouseId, this.form.orgId)
  219. })
  220. },
  221. getDataParam() {
  222. return this.editData.ssSafeGrainStorageInspectionId
  223. },
  224. getDataFun() {
  225. return getDetail
  226. },
  227. getGrainInfo(storehouseId, warehouseId, orgId) {
  228. return getGrain({
  229. storehouseId,
  230. warehouseId,
  231. orgId
  232. }).then(resp => {
  233. if (resp && resp.data) {
  234. this.form.grainGradeName = resp.data.grainGradeName
  235. this.form.grainVarietyName = resp.data.grainVarietyName
  236. this.form.grainVarietyId = resp.data.grainVarietyId
  237. this.form.grainGradeId = resp.data.grainGradeId
  238. }
  239. })
  240. },
  241. parseResp(resp) {
  242. const d = resp.data
  243. parseField2SomeType(d, ['rodentCheck', 'isCondensation', 'moldCondition', 'isLump', 'isLeakage',
  244. 'isReturnDamp', 'isPest'
  245. ], (v) => {
  246. if (v === true) return 1
  247. else if (v === false) return 0
  248. return v
  249. })
  250. /// for debug
  251. // d.images = 'http://172.16.0.36:15772/province-qinghai/2024/6/14/1801530630927626241.png'
  252. /// for debug
  253. return d
  254. },
  255. houseChanged(n, o) {
  256. this.form.storehouseName = o?.raw?.storehouseName
  257. // console.log(this.form.storehouseName);
  258. this.form.warehouseId = null
  259. this.getWareOptions(n, this.form.orgId)
  260. },
  261. wareChanged(n, o) {
  262. this.form.warehouseName = o?.raw?.warehouseName
  263. // console.log(this.form.warehouseName);
  264. if (n) {
  265. this.getGrainInfo(this.form.basicStorehouseId, this.form.warehouseId, this.form.orgId)
  266. }
  267. },
  268. uploadChanged(n) {
  269. const list = n || []
  270. this.form.images = n.map(d => d.url).join(',')
  271. console.log(this.form.images, n, list);
  272. },
  273. getLocalData() {
  274. const d = {
  275. ...this.form
  276. }
  277. d.ssSafeGrainStorageInspectionId = d.ssSafeGrainStorageInspectionId || this.editData
  278. .ssSafeGrainStorageInspectionId
  279. parseField2SomeType(d, ['rodentCheck', 'isCondensation', 'moldCondition', 'isLump', 'isLeakage',
  280. 'isReturnDamp', 'isPest'
  281. ], (v) => {
  282. if (v === 1) return true
  283. else if (v === 0) return false
  284. return null
  285. })
  286. deleteField(d, [
  287. 'id', 'createTime', 'createUser', 'updateTime', 'updateUser',
  288. 'warehouseName', 'orgName', 'storehouseName', 'orgId', 'grainGradeName', 'grainVarietyName'
  289. ])
  290. return d
  291. },
  292. getSaveFun() {
  293. return update
  294. }
  295. }
  296. }
  297. </script>
  298. <style lang="scss">
  299. .content {
  300. padding: 10px;
  301. .buttons {
  302. display: flex;
  303. justify-content: flex-end;
  304. .btn {
  305. max-width: 100px;
  306. margin: 10px;
  307. }
  308. }
  309. .form {
  310. .item {
  311. margin-left: 12px;
  312. ;
  313. }
  314. }
  315. }
  316. </style>