IotDeviceForm.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <template>
  2. <ContentWrap v-loading="formLoading">
  3. <el-form ref="formRef" :model="formData" :rules="formRules" style="margin-right: 4em;margin-left: 0.5em" label-width="130px">
  4. <div class="title-div">
  5. <el-button @click="baseInfoClick" class="title-button">
  6. <Icon color="black" icon="ep:set-up" :size="18" class="cursor-pointer first-icon" />
  7. <span class="cursor-pointer">基本信息</span>
  8. <Icon
  9. color="black"
  10. :icon="baseIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
  11. :size="18"
  12. class="cursor-pointer"
  13. />
  14. </el-button>
  15. </div>
  16. <div class="base-expandable-content" :class="{ 'is-expanded': baseIsExpanded }">
  17. <el-row>
  18. <el-col :span="8">
  19. <el-form-item label="资产编码" prop="deviceCode">
  20. <el-input v-model="formData.deviceCode" placeholder="请输入资产编码" />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="8">
  24. <el-form-item label="设备名称" prop="deviceName">
  25. <el-input v-model="formData.deviceName" placeholder="请输入设备名称" />
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="8">
  29. <el-form-item label="品牌" prop="brandName">
  30. <el-select
  31. clearable
  32. v-model="formData.brandName"
  33. @clear="brandClear"
  34. placeholder="请输入品牌"
  35. @click="openForm"
  36. />
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="8">
  40. <el-form-item label="所在部门" prop="deptId">
  41. <el-tree-select
  42. v-model="formData.deptId"
  43. :data="deptList"
  44. :props="defaultProps"
  45. check-strictly
  46. node-key="id"
  47. placeholder="请选择所在部门"
  48. />
  49. <!-- <el-tree-select-->
  50. <!-- v-model="formData.deptId"-->
  51. <!-- :data="deptList"-->
  52. <!-- :props="defaultProps"-->
  53. <!-- check-strictly-->
  54. <!-- node-key="id"-->
  55. <!-- placeholder="请选择归属部门"-->
  56. <!-- />-->
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="8">
  60. <el-form-item label="设备类别" prop="assetClass">
  61. <el-tree-select
  62. v-model="formData.assetClass"
  63. :data="productClassifyList"
  64. :props="defaultProps"
  65. check-strictly
  66. node-key="id"
  67. placeholder="请选择设备类别"
  68. @change="assetclasschange"
  69. filterable
  70. />
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="8">
  74. <el-form-item label="设备状态" prop="deviceStatus">
  75. <el-select v-model="formData.deviceStatus" placeholder="请选择" clearable>
  76. <el-option
  77. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_DEVICE_STATUS)"
  78. :key="dict.label"
  79. :label="dict.label"
  80. :value="dict.value"
  81. />
  82. </el-select>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="8">
  86. <el-form-item label="资产性质" prop="deviceStatus">
  87. <el-select v-model="formData.assetProperty" placeholder="请选择" clearable>
  88. <el-option
  89. v-for="dict in getStrDictOptions(DICT_TYPE.PMS_ASSET_PROPERTY)"
  90. :key="dict.id"
  91. :label="dict.label"
  92. :value="dict.value"
  93. />
  94. </el-select>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="8" >
  98. <div style="display: flex;flex-direction: row">
  99. <el-form-item label="规格型号" prop="model" style="width: 86%">
  100. <el-input
  101. clearable
  102. v-model="formData.model"
  103. placeholder="请输入规格型号"
  104. />
  105. </el-form-item>
  106. <el-button type="info" @click="openModelForm">请选择</el-button>
  107. </div>
  108. </el-col>
  109. <el-col :span="8">
  110. <el-form-item label="图片" prop="picUrl">
  111. <UploadImg v-model="formData.picUrl" :disabled="isDetail" height="60px" />
  112. </el-form-item>
  113. </el-col>
  114. <el-col :span="24">
  115. <el-form-item label="备注" prop="remark">
  116. <el-input v-model="formData.remark" type="textarea" placeholder="请输入备注" />
  117. </el-form-item>
  118. </el-col>
  119. </el-row>
  120. </div>
  121. <div class="title-div">
  122. <el-button @click="zzInfoClick" class="title-button">
  123. <Icon color="black" icon="ep:set-up" :size="18" class="cursor-pointer first-icon" />
  124. <span class="cursor-pointer">制造信息</span>
  125. <Icon
  126. color="black"
  127. :icon="zzIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
  128. :size="18"
  129. class="cursor-pointer"
  130. />
  131. </el-button>
  132. </div>
  133. <div class="zz-expandable-content" :class="{ 'is-expanded': zzIsExpanded }">
  134. <el-row>
  135. <el-col :span="8">
  136. <el-form-item label="制造商" prop="manufacturerId">
  137. <el-select
  138. clearable
  139. @clear="zzClear"
  140. v-model="formData.manufacturerName"
  141. placeholder="请输入制造商"
  142. @click="openCustomerZz"
  143. />
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="8">
  147. <el-form-item label="生产日期" prop="manDate">
  148. <el-date-picker
  149. style="width: 150%"
  150. v-model="formData.manDate"
  151. type="date"
  152. value-format="x"
  153. placeholder="选择生产日期"
  154. />
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="8">
  158. <el-form-item label="供应商" prop="supplierId">
  159. <el-select
  160. clearable
  161. @clear="supplierClear"
  162. v-model="formData.supplierName"
  163. placeholder="请输入供应商"
  164. @click="openCustomerSupplier"
  165. />
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="8">
  169. <el-form-item label="质保到期" prop="expires">
  170. <el-date-picker
  171. style="width: 150%"
  172. v-model="formData.expires"
  173. type="date"
  174. value-format="x"
  175. placeholder="选择质保到期"
  176. />
  177. </el-form-item>
  178. </el-col>
  179. <el-col :span="16">
  180. <el-form-item label="铭牌信息" prop="nameplate">
  181. <el-input v-model="formData.nameplate" type="textarea" placeholder="请输入铭牌信息" />
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. </div>
  186. <div class="title-div">
  187. <el-button @click="cwInfoClick" class="title-button">
  188. <Icon color="black" icon="ep:set-up" :size="18" class="cursor-pointer first-icon" />
  189. <span class="cursor-pointer">财务信息</span>
  190. <Icon
  191. color="black"
  192. :icon="cwIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
  193. :size="18"
  194. class="cursor-pointer"
  195. />
  196. </el-button>
  197. </div>
  198. <div class="cw-expandable-content" :class="{ 'is-expanded': cwIsExpanded }">
  199. <el-row>
  200. <el-col :span="8">
  201. <el-form-item :label="formData.assetProperty==='zy'?'采购价格':'租赁价格'" prop="plPrice">
  202. <el-input
  203. v-model="formData.plPrice"
  204. @input="handleInput(formData.plPrice, 'plPrice')"
  205. :placeholder="formData.assetProperty==='zy'?'请输入采购价格':'请输入租赁价格'"
  206. />
  207. </el-form-item>
  208. </el-col>
  209. <el-col :span="8">
  210. <el-form-item :label="formData.assetProperty==='zy'?'采购日期':'租赁日期'" prop="plDate">
  211. <el-date-picker
  212. style="width: 150%"
  213. v-model="formData.plDate"
  214. type="date"
  215. value-format="x"
  216. :placeholder="formData.assetProperty==='zy'?'请输入采购日期':'请输入租赁日期'"
  217. />
  218. </el-form-item>
  219. </el-col>
  220. <el-col :span="8">
  221. <el-form-item :label="formData.assetProperty==='zy'?'折旧年限':'租赁年限'" prop="plYear">
  222. <el-input v-model="formData.plYear" type="number" :placeholder="formData.assetProperty==='zy'?'请输入折旧年限':'请输入租赁年限'" />
  223. </el-form-item>
  224. </el-col>
  225. <el-col :span="8">
  226. <el-form-item :label="formData.assetProperty==='zy'?'折旧开始日期':'租赁开始日期'" prop="plStartDate">
  227. <el-date-picker
  228. style="width: 150%"
  229. v-model="formData.plStartDate"
  230. type="date"
  231. value-format="x"
  232. :placeholder="formData.assetProperty==='zy'?'请选择折旧开始日期':'请选择租赁开始日期'"
  233. />
  234. </el-form-item>
  235. </el-col>
  236. <el-col :span="8">
  237. <el-form-item :label="formData.assetProperty==='zy'?'已提折旧月数':'已租赁月数'" prop="plMonthed">
  238. <el-input
  239. v-model="formData.plMonthed"
  240. type="number"
  241. :placeholder="formData.assetProperty==='zy'?'请输入已提折旧月数':'请输入已租赁月数'"
  242. />
  243. </el-form-item>
  244. </el-col>
  245. <el-col :span="8">
  246. <el-form-item :label="formData.assetProperty==='zy'?'已提折旧金额':'已租赁金额'" prop="plAmounted">
  247. <el-input
  248. v-model="formData.plAmounted"
  249. @input="handleInput(formData.plAmounted, 'plAmounted')"
  250. :placeholder="formData.assetProperty==='zy'?'请输入已提折旧金额':'已租赁金额'"
  251. />
  252. </el-form-item>
  253. </el-col>
  254. <el-col :span="8">
  255. <el-form-item label="剩余金额" prop="remainAmount">
  256. <el-input
  257. v-model="formData.remainAmount"
  258. @input="handleInput(formData.remainAmount, 'remainAmount')"
  259. placeholder="请输入剩余金额"
  260. />
  261. </el-form-item>
  262. </el-col>
  263. </el-row>
  264. </div>
  265. <div class="title-div">
  266. <el-button @click="qtInfoClick" class="title-button">
  267. <Icon color="black" icon="ep:set-up" :size="18" class="cursor-pointer first-icon" />
  268. <span class="cursor-pointer">其它信息</span>
  269. <Icon
  270. color="black"
  271. :icon="qtIsExpanded ? 'fa-solid:angle-double-down' : 'fa-solid:angle-double-right'"
  272. :size="18"
  273. class="cursor-pointer"
  274. />
  275. </el-button>
  276. </div>
  277. <div class="qt-expandable-content" :class="{ 'is-expanded': qtIsExpanded }">
  278. <el-row>
  279. <el-col v-for="field in list" :key="field.sort" :span="8">
  280. <el-form-item :label="field.name" :prop="field.code" :rules="field.rules">
  281. <!-- 文本输入 -->
  282. <el-input
  283. v-if="field.type === 'text'"
  284. v-model="formData[field.code]"
  285. :placeholder="'请输入' + field.name"
  286. :type="field.type || 'text'"
  287. />
  288. <el-select
  289. v-else-if="field.type === 'enum'"
  290. v-model="formData[field.code]"
  291. :placeholder="'请输入'+field.name"
  292. clearable
  293. filterable
  294. >
  295. <el-option
  296. v-for="item in field.selectOptions.dataSpecsList"
  297. :key="item.value"
  298. :label="item.name"
  299. :value="item.value"
  300. />
  301. </el-select>
  302. <!-- 数字输入 -->
  303. <el-input
  304. v-else-if="field.type === 'int'"
  305. type="number"
  306. v-model="formData[field.code]"
  307. style="width: 150%"
  308. />
  309. <el-input
  310. v-else-if="field.type === 'double'"
  311. v-model="formData[field.code]"
  312. @input="handleInput(formData[field.code], field.code)"
  313. style="width: 150%"
  314. />
  315. <!-- 日期选择 -->
  316. <el-date-picker
  317. v-else-if="field.type === 'date'"
  318. v-model="formData[field.code]"
  319. :type="field.type || 'date'"
  320. :placeholder="'请输入' + field.name"
  321. value-format="YYYY-MM-DD"
  322. style="width: 150%"
  323. />
  324. </el-form-item>
  325. </el-col>
  326. </el-row>
  327. </div>
  328. </el-form>
  329. <el-form>
  330. <el-form-item style="float: right">
  331. <el-button type="success" @click="allzhankai">一键展开</el-button>
  332. <el-button type="info" @click="allshouqi">一键收起</el-button>
  333. <el-button v-if="!isDetail" :loading="formLoading" type="warning" @click="submitForm">
  334. 保存
  335. </el-button>
  336. <el-button @click="close" type="primary">返回</el-button>
  337. </el-form-item>
  338. </el-form>
  339. </ContentWrap>
  340. <BrandList ref="brandFormRef" @choose="brandChoose" />
  341. <ModelList ref="modelFormRef" @choose="modelChoose" :brand = "formData.brand" />
  342. <CustomerList ref="customerZzFormRef" @choose="customerZzChoose" />
  343. <CustomerList ref="customerSupplierFormRef" @choose="customerSupplierChoose" />
  344. </template>
  345. <script setup lang="ts">
  346. import { IotDeviceApi, IotDeviceVO } from '@/api/pms/device'
  347. import BrandList from '@/views/pms/device/BrandList.vue'
  348. import ModelList from '@/views/pms/device/ModelList.vue'
  349. import CustomerList from '@/views/pms/device/CustomerList.vue'
  350. import { defaultProps, handleTree } from '@/utils/tree'
  351. import * as DeptApi from '@/api/system/dept'
  352. import * as ProductClassifyApi from '@/api/pms/productclassify'
  353. import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
  354. import { useTagsViewStore } from '@/store/modules/tagsView'
  355. import {DeviceAttrModelApi} from "@/api/pms/deviceattrmodel";
  356. /** 设备台账 表单 */
  357. defineOptions({ name: 'DeviceDetailAdd' })
  358. const baseIsExpanded = ref(true) // 控制表单是否展开的变量
  359. const zzIsExpanded = ref(true) // 控制表单是否展开的变量
  360. const cwIsExpanded = ref(true) // 控制表单是否展开的变量
  361. const qtIsExpanded = ref(true) // 控制表单是否展开的变量
  362. const deptList = ref<Tree[]>([]) // 树形结构
  363. const productClassifyList = ref<Tree[]>([]) // 树形结构
  364. const { delView } = useTagsViewStore() // 视图操作
  365. const { params, name } = useRoute() // 查询参数
  366. const { currentRoute, push } = useRouter()
  367. const id = params.id
  368. const type = params.type
  369. const deptId = params.deptId
  370. const isDetail = params.isDetail
  371. const { t } = useI18n() // 国际化
  372. const message = useMessage() // 消息弹窗
  373. const dialogVisible = ref(false) // 弹窗的是否展示
  374. const dialogTitle = ref('') // 弹窗的标题
  375. const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
  376. const formType = ref('') // 表单的类型:create - 新增;update - 修改
  377. const brandLabel = ref('') // 表单的类型:create - 新增;update - 修改
  378. const zzLabel = ref('') // 表单的类型:create - 新增;update - 修改
  379. const supplierLabel = ref('') // 表单的类型:create - 新增;update - 修改
  380. const formData = ref({
  381. id: undefined,
  382. deviceCode: undefined,
  383. deviceName: undefined,
  384. brand: undefined,
  385. brandName: undefined,
  386. model: undefined,
  387. deptId: undefined,
  388. deviceStatus: undefined,
  389. assetProperty: undefined,
  390. picUrl: undefined,
  391. remark: undefined,
  392. manufacturerId: undefined,
  393. manufacturerName: undefined,
  394. supplierId: undefined,
  395. supplierName: undefined,
  396. manDate: undefined,
  397. nameplate: undefined,
  398. expires: undefined,
  399. plPrice: undefined,
  400. plDate: undefined,
  401. plYear: undefined,
  402. plStartDate: undefined,
  403. plMonthed: undefined,
  404. plAmounted: undefined,
  405. remainAmount: undefined,
  406. infoId: undefined,
  407. infoType: undefined,
  408. infoName: undefined,
  409. infoRemark: undefined,
  410. infoUrl: undefined,
  411. templateJson: undefined,
  412. assetClass: undefined
  413. })
  414. const formRules = reactive({
  415. assetClass: [{ required: true, message: '资产类别不能为空', trigger: 'blur' }],
  416. deviceCode: [{ required: true, message: '资产编码不能为空', trigger: 'blur' }],
  417. deviceName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
  418. brand: [{ required: true, message: '品牌不能为空', trigger: 'blur' }],
  419. deptId: [{ required: true, message: '所在部门不能为空', trigger: 'blur' }],
  420. deviceStatus: [{ required: true, message: '设备状态不能为空', trigger: 'blur' }],
  421. assetProperty: [{ required: true, message: '资产性质不能为空', trigger: 'blur' }],
  422. manufacturerId: [{ required: true, message: '制造商id不能为空', trigger: 'blur' }],
  423. manDate: [{ required: true, message: '生产日期不能为空', trigger: 'blur' }]
  424. })
  425. const list = ref([])
  426. const assetclasschange = () => {
  427. const assetClass = formData.value.assetClass
  428. DeviceAttrModelApi.getDeviceAttrModelListByDeviceCategoryId(assetClass).then(res => {
  429. if (res){
  430. res.forEach((item) => {
  431. if (item.requiredFlag) {
  432. const rule = {required: true, message: item.name+'不能为空', trigger: 'blur'}
  433. item.rules = []
  434. item.rules.push(rule)
  435. }
  436. })
  437. list.value = res
  438. } else {
  439. list.value = []
  440. }
  441. })
  442. }
  443. const brandChoose = (row) => {
  444. formData.value.brand = row.id
  445. // brandLabel.value = row.value
  446. formData.value.brandName = row.label
  447. }
  448. const brandClear = () =>{
  449. formData.value.brand = undefined
  450. formData.value.brandName = undefined
  451. }
  452. const modelChoose = (row) => {
  453. formData.value.model = row.name
  454. }
  455. const customerSupplierChoose = (row) => {
  456. formData.value.supplierId = row.id
  457. formData.value.supplierName = row.name
  458. // supplierLabel.value = row.name
  459. }
  460. const supplierClear = (row) => {
  461. formData.value.supplierId = undefined
  462. formData.value.supplierName = undefined
  463. }
  464. const customerZzChoose = (row) => {
  465. formData.value.manufacturerId = row.id
  466. // zzLabel.value = row.name
  467. formData.value.manufacturerName = row.name
  468. }
  469. const zzClear = () =>{
  470. formData.value.manufacturerId = undefined
  471. formData.value.manufacturerName = undefined
  472. }
  473. /** 添加/修改操作 */
  474. const brandFormRef = ref()
  475. const openForm = () => {
  476. brandFormRef.value.open()
  477. }
  478. const modelFormRef = ref()
  479. const openModelForm = () =>{
  480. modelFormRef.value.open()
  481. }
  482. const customerSupplierFormRef = ref()
  483. const openCustomerSupplier = () => {
  484. customerSupplierFormRef.value.open()
  485. }
  486. const customerZzFormRef = ref()
  487. const openCustomerZz = () => {
  488. customerZzFormRef.value.open()
  489. }
  490. const allshouqi = () => {
  491. baseIsExpanded.value = false
  492. zzIsExpanded.value = false
  493. cwIsExpanded.value = false
  494. qtIsExpanded.value = false
  495. }
  496. const allzhankai = () => {
  497. baseIsExpanded.value = true
  498. zzIsExpanded.value = true
  499. cwIsExpanded.value = true
  500. qtIsExpanded.value = true
  501. }
  502. const handleInput = (value, obj) => {
  503. // 1. 过滤非法字符(只允许数字和小数点)
  504. let filtered = value.replace(/[^\d.]/g, '')
  505. // 2. 处理多个小数点的情况
  506. filtered = filtered.replace(/\.{2,}/g, '.')
  507. // 3. 限制小数点后最多两位
  508. let decimalParts = filtered.split('.')
  509. if (decimalParts.length > 1) {
  510. decimalParts = decimalParts.slice(0, 2)
  511. filtered = decimalParts.join('.')
  512. }
  513. // 4. 处理以小数点开头的情况(自动补0)
  514. if (filtered.startsWith('.')) {
  515. filtered = '0' + filtered
  516. }
  517. // 5. 更新绑定值(同时处理连续输入多个0的情况)
  518. formData.value[obj] = filtered.replace(/^0+(?=\d)/, '')
  519. }
  520. const close = () => {
  521. delView(unref(currentRoute))
  522. push({ name: 'IotDevicePms', params:{}})
  523. // delView(unref(currentRoute))
  524. // push({
  525. // name: 'IotDevicePms',
  526. // query: {
  527. // date: new Date().getTime()
  528. // }
  529. // })
  530. }
  531. const baseInfoClick = () => {
  532. baseIsExpanded.value = !baseIsExpanded.value // 切换展开状态
  533. }
  534. const zzInfoClick = () => {
  535. zzIsExpanded.value = !zzIsExpanded.value // 切换展开状态
  536. }
  537. const cwInfoClick = () => {
  538. cwIsExpanded.value = !cwIsExpanded.value // 切换展开状态
  539. }
  540. const qtInfoClick = () => {
  541. qtIsExpanded.value = !qtIsExpanded.value // 切换展开状态
  542. }
  543. /** 提交表单 */
  544. const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
  545. const formRef = ref()
  546. const submitForm = async () => {
  547. // 校验表单
  548. await formRef.value.validate()
  549. // 提交请求
  550. formLoading.value = true
  551. try {
  552. if (list.value) {
  553. list.value = list.value.map(item => ({
  554. ...item,
  555. value: formData.value[item.code] // 自定义属性生成逻辑
  556. }))
  557. formData.value.templateJson = JSON.stringify(list.value)
  558. }
  559. const data = formData.value as unknown as IotDeviceVO
  560. if (formType.value === 'create') {
  561. await IotDeviceApi.createIotDevice(data)
  562. message.success(t('common.createSuccess'))
  563. } else {
  564. await IotDeviceApi.updateIotDevice(data)
  565. message.success(t('common.updateSuccess'))
  566. }
  567. dialogVisible.value = false
  568. // 发送操作成功的事件
  569. //emit('success')
  570. close()
  571. } finally {
  572. formLoading.value = false
  573. }
  574. }
  575. onMounted(async () => {
  576. deptList.value = handleTree(await DeptApi.getSimpleDeptList())
  577. productClassifyList.value = handleTree(
  578. await ProductClassifyApi.IotProductClassifyApi.getSimpleProductClassifyList()
  579. )
  580. formData.value.assetProperty = 'zy'
  581. // 修改时,设置数据
  582. if (id) {
  583. formType.value = 'update';
  584. formLoading.value = true
  585. try {
  586. const iotDevice = await IotDeviceApi.getIotDevice(id);
  587. formData.value = iotDevice
  588. formData.value.brandName = iotDevice.brandName;
  589. formData.value.manufacturerName = iotDevice.zzName;
  590. formData.value.supplierName = iotDevice.supplierName;
  591. list.value = JSON.parse(iotDevice.templateJson);
  592. list.value.forEach((item) => {
  593. formData.value[item.code] = item.value;
  594. })
  595. } finally {
  596. formLoading.value = false
  597. }
  598. } else {
  599. formData.value.deptId = Number(deptId)
  600. formType.value = 'create';
  601. }
  602. })
  603. /** 重置表单 */
  604. const resetForm = () => {
  605. formData.value = {
  606. id: undefined,
  607. deviceCode: undefined,
  608. deviceName: undefined,
  609. brand: undefined,
  610. model: undefined,
  611. deptId: undefined,
  612. deviceStatus: undefined,
  613. assetProperty: undefined,
  614. picUrl: undefined,
  615. remark: undefined,
  616. manufacturerId: undefined,
  617. supplierId: undefined,
  618. manDate: undefined,
  619. nameplate: undefined,
  620. expires: undefined,
  621. plPrice: undefined,
  622. plDate: undefined,
  623. plYear: undefined,
  624. plStartDate: undefined,
  625. plMonthed: undefined,
  626. plAmounted: undefined,
  627. remainAmount: undefined,
  628. infoId: undefined,
  629. infoType: undefined,
  630. infoName: undefined,
  631. infoRemark: undefined,
  632. infoUrl: undefined,
  633. templateJson: undefined,
  634. assetClass: undefined,
  635. }
  636. formRef.value?.resetFields()
  637. }
  638. </script>
  639. <style scoped lang="scss">
  640. .base-expandable-content {
  641. max-height: 0; /* 初始高度为0 */
  642. overflow: hidden; /* 隐藏溢出的内容 */
  643. transition: max-height 0.3s ease; /* 平滑过渡效果 */
  644. }
  645. .base-expandable-content.is-expanded {
  646. min-height: 260px; /* 或者根据内容设定一个合适的最大高度 */
  647. }
  648. .zz-expandable-content {
  649. max-height: 0; /* 初始高度为0 */
  650. overflow: hidden; /* 隐藏溢出的内容 */
  651. transition: max-height 0.3s ease; /* 平滑过渡效果 */
  652. }
  653. .zz-expandable-content.is-expanded {
  654. min-height: 130px; /* 或者根据内容设定一个合适的最大高度 */
  655. }
  656. .cw-expandable-content {
  657. max-height: 0; /* 初始高度为0 */
  658. overflow: hidden; /* 隐藏溢出的内容 */
  659. transition: max-height 0.3s ease; /* 平滑过渡效果 */
  660. }
  661. .cw-expandable-content.is-expanded {
  662. max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
  663. }
  664. .qt-expandable-content {
  665. max-height: 0; /* 初始高度为0 */
  666. overflow: hidden; /* 隐藏溢出的内容 */
  667. transition: max-height 0.3s ease; /* 平滑过渡效果 */
  668. }
  669. .qt-expandable-content.is-expanded {
  670. max-height: 200px; /* 或者根据内容设定一个合适的最大高度 */
  671. }
  672. .title-button{
  673. font-size: 18px;
  674. border: none;
  675. }
  676. .title-div{
  677. margin-bottom: 20px;
  678. margin-top: 10px;
  679. }
  680. .cursor-pointer{
  681. vertical-align: middle;
  682. }
  683. .first-icon{
  684. margin-bottom: 2px;
  685. }
  686. </style>