index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. <template>
  2. <view class="page detail">
  3. <view class="form-content" style="height: 100%; overflow-y: auto">
  4. <uni-forms ref="formRef" :model-value="form" :rules="rules" err-show-type="toast" labelWidth="140px">
  5. <uni-section :title="$t('ledger.form.basicInfo')">
  6. <view class="card">
  7. <!-- 填写设备编码 -->
  8. <uni-forms-item class="form-item" name="deviceCode" :label="$t('ledger.form.deviceCode')" required>
  9. <uni-easyinput
  10. v-model="form.deviceCode"
  11. :inputBorder="false"
  12. :clearable="false"
  13. :styles="{disableColor:'#fff'}"
  14. :placeholder="$t('operation.PleaseFillIn')"
  15. style="text-align: right"
  16. />
  17. </uni-forms-item>
  18. <!-- 填写设备名称 -->
  19. <uni-forms-item class="form-item" name="deviceName" :label="$t('ledger.form.deviceName')" required>
  20. <uni-easyinput
  21. v-model="form.deviceName"
  22. :inputBorder="false"
  23. :clearable="false"
  24. :styles="{disableColor:'#fff'}"
  25. :placeholder="$t('operation.PleaseFillIn')"
  26. style="text-align: right"
  27. />
  28. </uni-forms-item>
  29. <!-- 选择品牌 -->
  30. <uni-forms-item class="form-item" name="brandName" :label="$t('ledger.form.brand')" required>
  31. <uni-easyinput
  32. class="input-readonly"
  33. v-model="form.brandName"
  34. :inputBorder="false"
  35. :clearable="false"
  36. :styles="{disableColor:'#fff'}"
  37. :placeholder="$t('operation.PleaseSelect')"
  38. style="text-align: right"
  39. @click.passive="selectBrand"
  40. />
  41. </uni-forms-item>
  42. <!-- 选择所在部门 -->
  43. <uni-forms-item class="form-item dept" name="deptList" :label="$t('ledger.form.dept')" required>
  44. <customthree-tree-select
  45. v-model="form.deptList"
  46. :list-data="deptTree"
  47. @select-change="onSelectDept"
  48. />
  49. </uni-forms-item>
  50. <!-- 选择设备类别 -->
  51. <uni-forms-item class="form-item dept" name="deviceTypeList" :label="$t('ledger.form.deviceType')" required>
  52. <customthree-tree-select
  53. v-model="form.deviceTypeList"
  54. :list-data="deviceTypeTree"
  55. @select-change="onSelectDeviceType"
  56. />
  57. </uni-forms-item>
  58. <!-- 选择设备状态 -->
  59. <uni-forms-item class="form-item" name="deviceStatus" :label="$t('ledger.form.deviceStatus')" required>
  60. <uni-data-picker
  61. class="hidden"
  62. v-model="form.deviceStatus"
  63. :popup-title="$t('ledger.form.deviceStatus')"
  64. :localdata="statusList"
  65. :clear-icon="false"
  66. :map="{ text: 'label', value: 'value' }"
  67. />
  68. </uni-forms-item>
  69. <!-- 选择资产性质 -->
  70. <uni-forms-item class="form-item" name="assetProperty" :label="$t('ledger.form.assetProperty')" required>
  71. <uni-data-select
  72. :localdata="assetPropertyList"
  73. field="value as value, label as text, label as label"
  74. format="{label}"
  75. :label="$t('operation.PleaseSelect')"
  76. v-model="form.assetProperty"
  77. :clear="false"
  78. />
  79. </uni-forms-item>
  80. <!-- 选择规格型号 -->
  81. <uni-forms-item class="form-item" name="modelName" :label="$t('ledger.form.model')">
  82. <uni-easyinput
  83. class="input-readonly"
  84. v-model="form.modelName"
  85. :inputBorder="false"
  86. :clearable="false"
  87. :styles="{disableColor:'#fff'}"
  88. :placeholder="$t('operation.PleaseSelect')"
  89. style="text-align: right"
  90. @click.passive="selectModel"
  91. />
  92. </uni-forms-item>
  93. <!-- 上传图片 -->
  94. <uni-forms-item class="form-item image" name="imageList" :label="$t('ledger.form.image')" style="padding-top: 25px; padding-bottom: 25px">
  95. <uni-file-picker
  96. v-model="form.imageList"
  97. file-mediatype="image"
  98. mode="grid"
  99. :auto-upload="false"
  100. :limit="1"
  101. @select="upload"
  102. >
  103. <template #default>
  104. <view class="flex-col align-center justify-center" style="width: 60px; height: 60px; background-color: #F4F4F4">
  105. <uni-icons type="plusempty" color="#ACACAC" size="12" />
  106. </view>
  107. </template>
  108. </uni-file-picker>
  109. </uni-forms-item>
  110. <!-- 填写备注 -->
  111. <uni-forms-item class="form-item no-border" name="infoRemark" :label="$t('ledger.form.remark')">
  112. <uni-easyinput
  113. v-model="form.infoRemark"
  114. :inputBorder="false"
  115. :clearable="false"
  116. :styles="{disableColor:'#fff'}"
  117. :placeholder="$t('operation.PleaseFillIn')"
  118. style="text-align: right"
  119. />
  120. </uni-forms-item>
  121. </view>
  122. </uni-section>
  123. <uni-section :title="$t('ledger.form.produceInfo')">
  124. <view class="card">
  125. <!-- 选择制造商 -->
  126. <uni-forms-item class="form-item" name="zzName" :label="$t('ledger.form.manufacturer')" required>
  127. <uni-easyinput
  128. class="input-readonly"
  129. v-model="form.zzName"
  130. :inputBorder="false"
  131. :clearable="false"
  132. :styles="{disableColor:'#fff'}"
  133. :placeholder="$t('operation.PleaseSelect')"
  134. style="text-align: right"
  135. @click.passive="selectManufacturer(1)"
  136. />
  137. </uni-forms-item>
  138. <!-- 选择生产日期-->
  139. <uni-forms-item class="form-item" name="manDate" :label="$t('ledger.form.manDate')" required>
  140. <uni-datetime-picker
  141. v-model="form.manDate"
  142. type="date"
  143. return-type="string"
  144. :placeholder="$t('operation.PleaseSelect')"
  145. :class="!form.manDate ? 'time-hint-color' : undefined"
  146. :border="false"
  147. />
  148. </uni-forms-item>
  149. <!-- 选择供应商 -->
  150. <uni-forms-item class="form-item" name="supplierName" :label="$t('ledger.form.supplier')">
  151. <uni-easyinput
  152. class="input-readonly"
  153. v-model="form.supplierName"
  154. :inputBorder="false"
  155. :clearable="false"
  156. :styles="{disableColor:'#fff'}"
  157. :placeholder="$t('operation.PleaseSelect')"
  158. style="text-align: right"
  159. @click.passive="selectManufacturer(2)"
  160. />
  161. </uni-forms-item>
  162. <!-- 选择质保到期 -->
  163. <uni-forms-item class="form-item" name="expires" :label="$t('ledger.form.expires')">
  164. <uni-datetime-picker
  165. v-model="form.expires"
  166. type="date"
  167. return-type="string"
  168. :placeholder="$t('operation.PleaseSelect')"
  169. :class="!form.expires ? 'time-hint-color' : undefined"
  170. :border="false"
  171. />
  172. </uni-forms-item>
  173. <!-- 填写铭牌信息 -->
  174. <uni-forms-item class="form-item no-border" name="nameplate" :label="$t('ledger.form.nameplate')">
  175. <uni-easyinput
  176. v-model="form.nameplate"
  177. :inputBorder="false"
  178. :clearable="false"
  179. :styles="{disableColor:'#fff'}"
  180. :placeholder="$t('operation.PleaseFillIn')"
  181. style="text-align: right"
  182. />
  183. </uni-forms-item>
  184. </view>
  185. </uni-section>
  186. <uni-section :title="$t('ledger.form.financeInfo')">
  187. <view class="card">
  188. <!-- 选择采购价格 -->
  189. <uni-forms-item class="form-item" name="plPrice" :label="$t('ledger.form.plPrice')">
  190. <uni-easyinput
  191. v-model="form.plPrice"
  192. type="number"
  193. :inputBorder="false"
  194. :clearable="false"
  195. :styles="{disableColor:'#fff'}"
  196. :placeholder="$t('operation.PleaseFillIn')"
  197. style="text-align: right"
  198. />
  199. </uni-forms-item>
  200. <!-- 选择采购日期 -->
  201. <uni-forms-item class="form-item" name="plDate" :label="$t('ledger.form.plDate')">
  202. <uni-datetime-picker
  203. v-model="form.plDate"
  204. type="date"
  205. return-type="string"
  206. :placeholder="$t('operation.PleaseSelect')"
  207. :class="!form.plDate ? 'time-hint-color' : undefined"
  208. :border="false"
  209. />
  210. </uni-forms-item>
  211. <!-- 填写折旧年限 -->
  212. <uni-forms-item class="form-item" name="plYear" :label="$t('ledger.form.plYear')">
  213. <uni-easyinput
  214. v-model="form.plYear"
  215. type="number"
  216. :inputBorder="false"
  217. :clearable="false"
  218. :styles="{disableColor:'#fff'}"
  219. :placeholder="$t('operation.PleaseFillIn')"
  220. style="text-align: right"
  221. />
  222. </uni-forms-item>
  223. <!-- 选择折旧开始日期 -->
  224. <uni-forms-item class="form-item" name="plStartDate" :label="$t('ledger.form.plStartDate')">
  225. <uni-datetime-picker
  226. v-model="form.plStartDate"
  227. type="date"
  228. return-type="string"
  229. :placeholder="$t('operation.PleaseSelect')"
  230. :class="!form.plStartDate ? 'time-hint-color' : undefined"
  231. :border="false"
  232. />
  233. </uni-forms-item>
  234. <!-- 填写已提折旧月数 -->
  235. <uni-forms-item class="form-item" name="plMonthed" :label="$t('ledger.form.plMonth')">
  236. <uni-easyinput
  237. v-model="form.plMonthed"
  238. type="number"
  239. :inputBorder="false"
  240. :clearable="false"
  241. :styles="{disableColor:'#fff'}"
  242. :placeholder="$t('operation.PleaseFillIn')"
  243. style="text-align: right"
  244. />
  245. </uni-forms-item>
  246. <!-- 填写已提折旧金额 -->
  247. <uni-forms-item class="form-item" name="plAmounted" :label="$t('ledger.form.plAmounted')">
  248. <uni-easyinput
  249. v-model="form.plAmounted"
  250. type="number"
  251. :inputBorder="false"
  252. :clearable="false"
  253. :styles="{disableColor:'#fff'}"
  254. :placeholder="$t('operation.PleaseFillIn')"
  255. style="text-align: right"
  256. />
  257. </uni-forms-item>
  258. <!-- 填写剩余金额 -->
  259. <uni-forms-item class="form-item no-border" name="remainAmount" :label="$t('ledger.form.remainAmount')">
  260. <uni-easyinput
  261. v-model="form.remainAmount"
  262. type="number"
  263. :inputBorder="false"
  264. :clearable="false"
  265. :styles="{disableColor:'#fff'}"
  266. :placeholder="$t('operation.PleaseFillIn')"
  267. style="text-align: right"
  268. />
  269. </uni-forms-item>
  270. </view>
  271. </uni-section>
  272. <view style="height: 50px"/>
  273. </uni-forms>
  274. </view>
  275. <button class="submit-btn" type="primary" @click="submit">{{ $t('operation.save') }}</button>
  276. <supplier-choose
  277. ref="manufacturerPopup"
  278. :selected-item-id="zzType === 1 ? form.manufacturerId : form.supplierId"
  279. @confirm="onSelectedManufacturer"
  280. />
  281. <brand-choose ref="brandPopup" :selected-item-id="form.brand" @confirm="onSelectBrand" />
  282. <model-choose ref="modelPopup" :selected-item-id="form.model" :brand-id="form.brand" @confirm="onSelectModel" />
  283. </view>
  284. </template>
  285. <script setup>
  286. import { reactive, ref, onMounted, nextTick, getCurrentInstance } from 'vue'
  287. import { useDataDictStore } from "@/store/modules/dataDict"
  288. import { getAllDeptList, getAllDeviceList, uploadFile } from "@/api"
  289. import { useDeptStore } from "@/store/modules/dept";
  290. import supplierChoose from '@/components/supplier/choose.vue'
  291. import brandChoose from "@/components/device/brandChoose.vue";
  292. import modelChoose from "@/components/device/modelChoose.vue";
  293. import { useDeviceStore } from "@/store/modules/device";
  294. import { submitDeviceLedger } from "@/api/ledger";
  295. const { deviceTypeTree } = useDeviceStore()
  296. const { deptTree } = useDeptStore()
  297. const { getDataDictList } = useDataDictStore()
  298. const statusList = ref([])
  299. const formRef = ref()
  300. const form = reactive({
  301. deviceCode: '',
  302. deviceName: '',
  303. brand: undefined,
  304. brandName: '',
  305. deptId: '',
  306. deptList: [],
  307. deviceStatus: '',
  308. deviceTypeList: [],
  309. assetClass: '',
  310. assetClassName: '',
  311. assetProperty: '',
  312. model: undefined,
  313. modelName: '',
  314. picUrl: '',
  315. imageList: [],
  316. infoRemark: '',
  317. manufacturerId: undefined,
  318. zzName: '',
  319. manDate: '',
  320. supplierId: undefined,
  321. supplierName: '',
  322. expires: '',
  323. nameplate: '',
  324. plPrice: '',
  325. plDate: '',
  326. plYear: '',
  327. plStartDate: '',
  328. plMonthed: '',
  329. plAmounted: '',
  330. remainAmount: '',
  331. })
  332. const { appContext } = getCurrentInstance()
  333. const t = appContext.config.globalProperties.$t
  334. const rules = reactive({
  335. deviceCode: { rules: [{ required: true, errorMessage: t('ledger.form.deviceCodeError') }] },
  336. deviceName: { rules: [{ required: true, errorMessage: t('ledger.form.deviceNameError') }] },
  337. brand: { rules: [{ required: true, errorMessage: t('ledger.form.brandError') }] },
  338. deptList: { rules: [{ required: true, errorMessage: t('ledger.form.deptError') }] },
  339. deviceTypeList: { rules: [{ required: true, errorMessage: t('ledger.form.deviceTypeError') }] },
  340. deviceStatus: { rules: [{ required: true, errorMessage: t('ledger.form.deviceStatusError') }] },
  341. assetProperty: { rules: [{ required: true, errorMessage: t('ledger.form.assetPropertyError') }] },
  342. zzName: { rules: [{ required: true, errorMessage: t('ledger.form.manufacturerError') }] },
  343. manDate: { rules: [{ required: true, errorMessage: t('ledger.form.manDateError') }] },
  344. })
  345. // 选择部门
  346. const onSelectDept = (item) => {
  347. if (item) {
  348. const list = JSON.parse(JSON.stringify(item))
  349. form.deptId = Array.isArray(list) && list.length > 0 ? list[0].id : undefined
  350. } else {
  351. form.deptId = undefined
  352. }
  353. }
  354. // 选择设备类型
  355. const onSelectDeviceType = (item) => {
  356. if (item) {
  357. const list = JSON.parse(JSON.stringify(item))
  358. if (Array.isArray(list) && list.length > 0) {
  359. form.assetClass = list[0].id
  360. form.assetClassName = list[0].name
  361. } else {
  362. form.assetClass = undefined
  363. form.assetClassName = undefined
  364. }
  365. } else {
  366. form.assetClass = undefined
  367. form.assetClassName = undefined
  368. }
  369. }
  370. // 品牌弹窗
  371. const brandPopup = ref()
  372. const selectBrand = () => {
  373. brandPopup.value.open('bottom')
  374. }
  375. const onSelectBrand = (item) => {
  376. form.brand = item.id
  377. form.brandName = item.label
  378. }
  379. // 规格弹窗
  380. const modelPopup = ref()
  381. const selectModel = () => {
  382. if (!form.brand) {
  383. uni.showToast({ title: t('ledger.brand.hint'), icon: 'none' })
  384. return
  385. }
  386. modelPopup.value.open('bottom')
  387. }
  388. const onSelectModel = (item) => {
  389. form.model = item.id
  390. form.modelName = item.name
  391. }
  392. // 制造商弹窗
  393. const zzType = ref()
  394. const manufacturerPopup = ref()
  395. const selectManufacturer = (type) => {
  396. zzType.value = type
  397. manufacturerPopup.value.open('bottom')
  398. }
  399. const onSelectedManufacturer = (item) => {
  400. if (zzType.value === 1) {
  401. form.manufacturerId = item.id
  402. form.zzName = item.name
  403. } else {
  404. form.supplierId = item.id
  405. form.supplierName = item.name
  406. }
  407. }
  408. // 上传图片
  409. const upload = async (event) => {
  410. for (const path of event.tempFilePaths) {
  411. form.picUrl = (await uploadFile(path)).data
  412. }
  413. }
  414. // 提交
  415. const submit = async () => {
  416. try {
  417. await formRef.value.validate()
  418. const { deptList, deviceTypeList, imageList, ...data } = form
  419. await submitDeviceLedger(data)
  420. uni.showToast({ title: t('statusChange.form.success'), icon: 'none' })
  421. uni.navigateBack()
  422. uni.$emit('update')
  423. } catch (e) {
  424. console.log(e)
  425. }
  426. }
  427. const assetPropertyList = ref([])
  428. const deviceList = ref([])
  429. const filterList = ref([])
  430. onMounted(async () => {
  431. assetPropertyList.value = getDataDictList('pms_asset_property') // 获取资产性质字典
  432. statusList.value = getDataDictList('pms_device_status') // 获取设备状态字典
  433. const deptList = (await getAllDeptList()).data
  434. for (const dept of deptList) {
  435. if (dept.name === '科瑞石油技术') {
  436. deviceList.value = (await getAllDeviceList(dept.id)).data
  437. filterList.value = deviceList.value
  438. break
  439. }
  440. }
  441. await nextTick(() => { // 输入框禁止输入
  442. const inputViews = document.getElementsByClassName('input-readonly');
  443. for (const view of inputViews) {
  444. view.readOnly = true
  445. }
  446. })
  447. })
  448. </script>
  449. <style lang="scss" scoped>
  450. @import "@/style/choose-device.scss";
  451. :deep(.uni-section) {
  452. background-color: transparent;
  453. }
  454. :deep(.uni-forms-item) {
  455. border-bottom: 1px dashed #CACCCF;
  456. margin: 0 20px;
  457. font-size: 13px;
  458. }
  459. .no-border {
  460. border-bottom: none;
  461. }
  462. :deep(.uni-forms-item__label) {
  463. color: #333333;
  464. font-weight: 500;
  465. font-size: 16px;
  466. }
  467. :deep(.image .uni-forms-item__label) {
  468. width: fit-content !important;
  469. }
  470. :deep(.file-picker__box) {
  471. width: 60px !important;
  472. height: 60px !important;
  473. padding: 0;
  474. }
  475. :deep(.uni-easyinput__content-input) {
  476. padding: 0 !important;
  477. }
  478. :deep(.uni-easyinput__placeholder-class) {
  479. font-size: 13px;
  480. }
  481. :deep(.input-value-border) {
  482. border: 0 !important;
  483. }
  484. :deep(.input-value) {
  485. text-align: end;
  486. padding-right: 0;
  487. }
  488. :deep(.hidden .uni-data-tree-dialog .selected-list) {
  489. display: none;
  490. }
  491. :deep(.selected-area .hidden) {
  492. display: block;
  493. margin-right: 5px;
  494. }
  495. :deep(.selected-area) {
  496. justify-content: end;
  497. font-size: 13px;
  498. }
  499. :deep(.uni-select) {
  500. padding-right: 0;
  501. .uni-select__input-placeholder {
  502. font-size: 13px;
  503. color: #999999;
  504. }
  505. .uni-icons {
  506. display: none;
  507. }
  508. }
  509. :deep(.placeholder) {
  510. color: #999999;
  511. }
  512. :deep(.selected-list) {
  513. justify-content: end;
  514. }
  515. :deep(.uni-data-pickerview) {
  516. display: block;
  517. }
  518. :deep(.uni-data-pickerview .selected-area .hidden) {
  519. display: none;
  520. }
  521. :deep(.tab-c .hidden) {
  522. margin-left: 30px;
  523. margin-right: 30px;
  524. border-top: 1px dashed #CACCCF;
  525. .item {
  526. border-bottom: 1px dashed #CACCCF !important;
  527. }
  528. }
  529. :deep(.uni-date-x) {
  530. text-align: right;
  531. color: inherit;
  532. padding-right: 0;
  533. .icon-calendar {
  534. display: none;
  535. font-size: 0;
  536. }
  537. .uni-date__x-input {
  538. font-size: inherit;
  539. padding-right: 0;
  540. }
  541. }
  542. :deep(.uni-select) {
  543. border: none;
  544. font-size: 13px !important;
  545. }
  546. :deep(.uni-select__input-text) {
  547. text-align: end;
  548. }
  549. :deep(.dept) {
  550. .uni-forms-item__content {
  551. display: flex;
  552. align-items: center;
  553. justify-content: end;
  554. }
  555. .select-list {
  556. border: none;
  557. min-height: 0;
  558. padding: 0;
  559. border-radius: 0;
  560. }
  561. .no-data {
  562. text-align: end;
  563. font-size: 13px;
  564. color: #999999 !important;
  565. }
  566. .select-items {
  567. justify-content: end;
  568. }
  569. .select-item {
  570. padding-right: 0 !important;
  571. margin: 0 !important;
  572. background-color: transparent !important;
  573. }
  574. .name {
  575. padding-right: 0 !important;
  576. }
  577. .close {
  578. display: none !important;
  579. }
  580. }
  581. :deep(.select-list .right) {
  582. display: none !important;
  583. }
  584. :deep(.arrow-area) {
  585. display: none;
  586. }
  587. .popup-content {
  588. height: 500px;
  589. }
  590. .device-item {
  591. height: 35px;
  592. line-height: 35px;
  593. padding: 0 30px;
  594. font-size: 13px;
  595. color: #333333;
  596. border-bottom: 1px #CACCCF;
  597. }
  598. .selected {
  599. color: #004098;
  600. }
  601. .divider {
  602. height: 0.5px;
  603. margin: 0 28px;
  604. background-color: #CACCCF;
  605. }
  606. .z-page-popup {
  607. padding: 0;
  608. background: white;
  609. border-radius: 10px 10px 0 0;
  610. }
  611. .submit-btn {
  612. width: 100%;
  613. height: 48px;
  614. border-radius: 0;
  615. position: fixed;
  616. bottom: 0;
  617. left: 0;
  618. }
  619. .card {
  620. background-color: white;
  621. }
  622. .time-hint-color {
  623. color: #999999;
  624. }
  625. .input-readonly {
  626. caret-color: transparent;
  627. }
  628. </style>