edit.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950
  1. <template>
  2. <div class="ele-body baseinfo-container">
  3. <el-card shadow="never">
  4. <div class="page-title">
  5. <el-page-header @back="$router.go(-1)">
  6. <div slot="content" class="pageContent">
  7. <div>{{ title }}</div>
  8. </div>
  9. </el-page-header>
  10. <div>
  11. <el-button type="primary" @click="submit" :loading="btnLoading"
  12. >确定</el-button
  13. >
  14. </div>
  15. </div>
  16. <el-form
  17. label-width="120px"
  18. :model="{ ...form, ...positionInfo }"
  19. ref="form"
  20. :rules="rules"
  21. >
  22. <div class="content">
  23. <div class="basic-details-title border-none">
  24. <span class="border-span">基本信息</span>
  25. </div>
  26. <el-descriptions title="" :column="4" size="medium" border>
  27. <template slot="title" v-if="pageType == 'add'">
  28. <el-form-item class="label-none" label-width="0">
  29. <span style="color: red; padding-right: 5px">*</span>
  30. <el-button type="primary" plain @click="handlwpbm"
  31. >选择物品编码</el-button
  32. >
  33. </el-form-item>
  34. </template>
  35. <el-descriptions-item>
  36. <template slot="label"> 设备编码 </template>
  37. <el-form-item
  38. prop="code"
  39. label-width="0"
  40. v-if="pageType == 'add'"
  41. >
  42. <el-input
  43. v-if="basicInfo"
  44. class="input"
  45. v-model="form.code"
  46. ></el-input>
  47. </el-form-item>
  48. <span v-if="pageType == 'edit'">{{ form.code }}</span>
  49. </el-descriptions-item>
  50. <el-descriptions-item>
  51. <template slot="label"> 设备名称 </template>
  52. <el-form-item
  53. prop="name"
  54. label-width="0"
  55. v-if="pageType == 'add'"
  56. >
  57. <el-input
  58. v-if="basicInfo"
  59. class="input"
  60. v-model="form.name"
  61. ></el-input>
  62. </el-form-item>
  63. <span v-if="pageType == 'edit'">{{ form.name }}</span>
  64. </el-descriptions-item>
  65. <el-descriptions-item>
  66. <template slot="label"> 型号</template>
  67. {{ assetInfo.modelType }}
  68. </el-descriptions-item>
  69. <el-descriptions-item>
  70. <template slot="label"> 规格 </template>
  71. {{ assetInfo.specification }}
  72. </el-descriptions-item>
  73. <el-descriptions-item :span="2">
  74. <template slot="label"> 分类 </template>
  75. {{ assetInfo.categoryLevelPath }}
  76. </el-descriptions-item>
  77. <el-descriptions-item>
  78. <template slot="label"> 生产日期 </template>
  79. <el-form-item
  80. prop="productTime"
  81. label-width="0"
  82. v-if="pageType == 'add'"
  83. >
  84. <el-date-picker
  85. v-if="basicInfo"
  86. v-model="form.productTime"
  87. type="datetime"
  88. placeholder="选择日期时间"
  89. value-format="yyyy-MM-dd HH:mm:ss"
  90. >
  91. </el-date-picker>
  92. </el-form-item>
  93. <span v-if="pageType == 'edit'">{{ form.productTime }}</span>
  94. </el-descriptions-item>
  95. <!-- <el-descriptions-item>
  96. <template slot="label"> 过保日期 </template>
  97. <span v-if="pageType == 'add'">{{ expirationTime }}</span>
  98. <span v-if="pageType == 'edit'">{{ cbexpirationTime }}</span>
  99. </el-descriptions-item> -->
  100. <el-descriptions-item>
  101. <template slot="label"> 计量单位 </template>
  102. {{ basicInfo.category&&basicInfo.category.measuringUnit }}
  103. </el-descriptions-item>
  104. <el-descriptions-item>
  105. <template slot="label"> 标准产能 </template>
  106. {{ setbzcn(basicInfo.extendField) }}
  107. </el-descriptions-item>
  108. <!-- <el-descriptions-item v-if="pageType == 'edit'">
  109. <template slot="label"> 实际产能 </template>
  110. {{ basicInfo.measuringUnit }}
  111. </el-descriptions-item> -->
  112. <el-descriptions-item v-if="pageType == 'edit'">
  113. <template slot="label"> 生命周期</template>
  114. {{ sourceDICT }}
  115. </el-descriptions-item>
  116. <el-descriptions-item v-if="pageType == 'edit'">
  117. <template slot="label"> 网络状态</template>
  118. {{ networkStatus === 1 ? '在线' : ( networkStatus === 0 ?'离线':'') }}
  119. </el-descriptions-item>
  120. </el-descriptions>
  121. <div class="basic-details-title border-none">
  122. <span class="border-span">资产信息</span>
  123. </div>
  124. <el-row>
  125. <el-col :span="8">
  126. <el-form-item label="固资编码">
  127. <el-input class="input" v-model="zcInfo.fixCode"></el-input>
  128. </el-form-item>
  129. </el-col>
  130. <el-col :span="8">
  131. <el-form-item label="颜色">
  132. <el-input class="input" v-model="zcInfo.color"></el-input>
  133. </el-form-item>
  134. </el-col>
  135. <el-col :span="8">
  136. <el-form-item label="重量">
  137. <el-input class="input" v-model="zcInfo.weight"></el-input>
  138. </el-form-item>
  139. </el-col>
  140. <el-col :span="8">
  141. <el-form-item label="维护部门">
  142. <div class="input">
  143. <DeptSelect v-model="zcInfo.repairGroupId" @input="getwhbm" />
  144. </div>
  145. </el-form-item>
  146. </el-col>
  147. <el-col :span="8">
  148. <el-form-item label="维护人">
  149. <el-select v-model="zcInfo.repairUserId" placeholder="请选择">
  150. <el-option
  151. v-for="item in options.repairUserId"
  152. :key="item.id"
  153. :label="item.name"
  154. :value="item.id"
  155. >
  156. </el-option>
  157. </el-select>
  158. </el-form-item>
  159. </el-col>
  160. <el-col :span="8">
  161. <el-form-item label="权属部门">
  162. <div class="input">
  163. <DeptSelect
  164. v-model="zcInfo.ownershipGroupId"
  165. @input="getqsbm"
  166. />
  167. </div>
  168. </el-form-item>
  169. </el-col>
  170. <el-col :span="8">
  171. <el-form-item label="权属人">
  172. <el-select
  173. v-model="zcInfo.ownershipUserId"
  174. placeholder="请选择"
  175. >
  176. <el-option
  177. v-for="item in options.ownershipUserId"
  178. :key="item.id"
  179. :label="item.name"
  180. :value="item.id"
  181. >
  182. </el-option>
  183. </el-select>
  184. </el-form-item>
  185. </el-col>
  186. <el-col :span="8">
  187. <el-form-item label="设备用途">
  188. <el-input v-model="zcInfo.purpose" class="input"></el-input>
  189. </el-form-item>
  190. </el-col>
  191. <!-- <el-col :span="8">
  192. <el-form-item label="所属工序">
  193. <WorkingProcedureSelect
  194. v-model="zcInfo.roteId"
  195. ></WorkingProcedureSelect>
  196. </el-form-item>
  197. </el-col> -->
  198. <el-col :span="8">
  199. <el-form-item label="品牌">
  200. <el-select v-model="zcInfo.brand" placeholder="请选择">
  201. <el-option
  202. v-for="item in options.brand"
  203. :key="item.id"
  204. :label="item.name"
  205. :value="item.id"
  206. >
  207. </el-option>
  208. </el-select>
  209. </el-form-item>
  210. </el-col>
  211. <el-col :span="8">
  212. <el-form-item label="供应商">
  213. <el-select v-model="zcInfo.supplierId" placeholder="请选择">
  214. <el-option
  215. v-for="item in options.supplierId"
  216. :key="item.id"
  217. :label="item.name"
  218. :value="item.id"
  219. >
  220. </el-option>
  221. </el-select>
  222. </el-form-item>
  223. </el-col>
  224. <el-col :span="8">
  225. <el-form-item label="所属厂房">
  226. <FactoryAreaSelect v-model="zcInfo.factoryRoomId" />
  227. <!-- <el-select
  228. v-model="zcInfo.factoryPlantCode"
  229. placeholder="请选择"
  230. >
  231. <el-option
  232. v-for="item in options.factoryPlantCode"
  233. :key="item.code"
  234. :label="item.name"
  235. :value="item.code"
  236. >
  237. </el-option>
  238. </el-select> -->
  239. </el-form-item>
  240. </el-col>
  241. <el-col :span="24">
  242. <el-form-item label="设备位置" required>
  243. <div class="sbwz">
  244. <el-row :gutter="12">
  245. <el-col :span="3">
  246. <el-form-item
  247. label=""
  248. label-width="0"
  249. prop="factoryCode"
  250. :rules="[
  251. {
  252. required: true,
  253. message: '请选择工厂',
  254. trigger: 'change'
  255. }
  256. ]"
  257. ><factorySelect
  258. v-model="positionInfo.factoryCode"
  259. placeholder="请选择工厂"
  260. @selfChange="hanldFactoryCode"
  261. /> </el-form-item
  262. ></el-col>
  263. <el-col :span="3">
  264. <el-form-item
  265. label=""
  266. label-width="0"
  267. prop="workshopCode"
  268. :rules="[
  269. {
  270. required: true,
  271. message: '请选择车间',
  272. trigger: 'change'
  273. }
  274. ]"
  275. >
  276. <WorkshopSelect
  277. ref="WorkshopSelectRef"
  278. :factoryId="positionInfo.factoryCode"
  279. v-model="positionInfo.workshopCode"
  280. @selfChange="hanldWorkshopCode"
  281. placeholder="请选择车间" /></el-form-item
  282. ></el-col>
  283. <el-col :span="3">
  284. <el-form-item
  285. label=""
  286. label-width="0"
  287. prop="lineCode"
  288. :rules="[
  289. {
  290. required: true,
  291. message: '请选择产线',
  292. trigger: 'change'
  293. }
  294. ]"
  295. >
  296. <FactoryLineSelect
  297. ref="FactoryLineSelectRef"
  298. :workshopId="positionInfo.workshopCode"
  299. v-model="positionInfo.lineCode"
  300. @selfChange="hanldlineCodeCode"
  301. placeholder="请选择产线"
  302. /> </el-form-item
  303. ></el-col>
  304. <el-col :span="4">
  305. <el-input
  306. class="item item-input"
  307. placeholder="详细地址"
  308. v-model="positionInfo.detailPosition"
  309. ></el-input
  310. ></el-col>
  311. </el-row>
  312. </div>
  313. </el-form-item>
  314. </el-col>
  315. </el-row>
  316. <div class="basic-details-title border-none">
  317. <span class="border-span">文档信息</span>
  318. </div>
  319. <div class="upload-container">
  320. <WithView v-model="imageUrl" :limit="1" />
  321. <div class="file-list">
  322. <div>
  323. <el-form-item prop="image" label="使用说明书">
  324. <fileUpload
  325. v-model="attUrl.operatingManual.value"
  326. module="main"
  327. :showLib="true"
  328. />
  329. </el-form-item>
  330. </div>
  331. <div>
  332. <el-form-item prop="image" label="生产许可证书">
  333. <fileUpload
  334. v-model="attUrl.productionLicence.value"
  335. module="main"
  336. :showLib="true"
  337. />
  338. </el-form-item>
  339. </div>
  340. <div>
  341. <el-form-item prop="image" label="防爆合格证书">
  342. <fileUpload
  343. v-model="attUrl.explosionProofCertificate.value"
  344. module="main"
  345. :showLib="true"
  346. />
  347. </el-form-item>
  348. </div>
  349. <div>
  350. <el-form-item prop="image" label="检验报告">
  351. <fileUpload
  352. v-model="attUrl.surveyReport.value"
  353. module="main"
  354. :showLib="true"
  355. />
  356. </el-form-item>
  357. </div>
  358. <div>
  359. <el-form-item prop="image" label="检验周期说明">
  360. <fileUpload
  361. v-model="attUrl.inspectionCycleManual.value"
  362. module="main"
  363. :showLib="true"
  364. />
  365. </el-form-item>
  366. </div>
  367. <div>
  368. <el-form-item prop="image" label="图纸资料">
  369. <fileUpload
  370. v-model="attUrl.informationDrawing.value"
  371. module="main"
  372. :showLib="true"
  373. />
  374. </el-form-item>
  375. </div>
  376. <div>
  377. <el-form-item prop="image" label="产品合格证">
  378. <fileUpload
  379. v-model="attUrl.productCertificate.value"
  380. module="main"
  381. :showLib="true"
  382. />
  383. </el-form-item>
  384. </div>
  385. </div>
  386. </div>
  387. <div class="basic-details-title border-none">
  388. <span class="border-span">物联参数</span>
  389. </div>
  390. <el-row>
  391. <el-col>
  392. <el-form-item label="是否启用物联">
  393. <el-switch
  394. v-model="isIotEnable"
  395. active-text="开"
  396. inactive-text="关"
  397. :active-value="1"
  398. :inactive-value="0"
  399. >
  400. </el-switch>
  401. </el-form-item>
  402. </el-col>
  403. <el-col>
  404. <el-form-item label="物联ID">{{ iotId }}</el-form-item>
  405. </el-col>
  406. </el-row>
  407. <div class="basic-details-title border-none">
  408. <span class="border-span">扩展信息</span>
  409. </div>
  410. <div class="kzzd">
  411. <el-row>
  412. <el-col
  413. :span="24"
  414. v-for="(item, index) in form.extInfoSelf"
  415. :key="index"
  416. style="margin-bottom: 20px"
  417. >
  418. <el-form-item
  419. label-width="0"
  420. :prop="'extInfoSelf.' + index + '.key'"
  421. :rules="{
  422. required: true,
  423. message: '自定义参数名称不能为空',
  424. trigger: 'blur'
  425. }"
  426. >
  427. <div class="add-col">
  428. <el-input
  429. class="col-input"
  430. v-model="item.key"
  431. placeholder="参数名称"
  432. ></el-input>
  433. <el-input
  434. class="col-input"
  435. v-model="item.value"
  436. placeholder="参数值"
  437. ></el-input>
  438. <el-button
  439. class="del"
  440. type="text"
  441. @click="delt(item, index)"
  442. >
  443. 删除
  444. </el-button>
  445. </div>
  446. </el-form-item>
  447. </el-col>
  448. <el-col :span="24" v-if="form.extInfoSelf.length < 10">
  449. <el-form-item label-width="0">
  450. <el-button
  451. class="primarybutton"
  452. type="primary"
  453. @click="addItem"
  454. >增加自定义参数</el-button
  455. >
  456. </el-form-item>
  457. </el-col>
  458. </el-row>
  459. </div>
  460. </div>
  461. </el-form>
  462. <DialogGoods
  463. ref="DialogGoods"
  464. @succeed="cbDialogGoods"
  465. width="1200px"
  466. ></DialogGoods>
  467. </el-card>
  468. </div>
  469. </template>
  470. <script>
  471. import DeptSelect from '@/components/CommomSelect/dept-select.vue';
  472. import FactoryLineSelect from '@/components/CommomSelect/factory-line-select.vue';
  473. import WorkshopSelect from '@/components/CommomSelect/workshop-select.vue';
  474. import FactoryAreaSelect from '@/components/CommomSelect/factory-area-select.vue';
  475. import WorkingProcedureSelect from '@/components/CommomSelect/working-procedure-select.vue';
  476. import factorySelect from '@/components/CommomSelect/factory-select.vue';
  477. import fileUpload from '@/components/upload/fileUpload';
  478. import WithView from '@/components/upload/WithView';
  479. import imgUpload from '@/components/upload/imgUpload';
  480. // import selectUpload from "@/components/selectUpload";
  481. // import UploadImg from "@/components/uploadImg/WithView.vue";
  482. import DialogGoods from './components/DialogGoods';
  483. // import { parseTime } from "@/utils/ruoyi.js";
  484. // import org from "@/api/main/org";
  485. // import user from "@/api/main/user";
  486. // import selectTree from "@/components/selectTree";
  487. // import dict from "@/api/main/craft/dict";
  488. // import { imageView } from "@/utils";
  489. // import {
  490. // getPlants,
  491. // getfactoryInfo,
  492. // getFactorys,
  493. // getProductionLine,
  494. // saveOrEdit,
  495. // getAssetNum,
  496. // getDetail,
  497. // getSupplier
  498. // } from '@/api/ledgerAssets/equipment';
  499. import { getFactoryarea } from '@/api/factoryModel';
  500. import { saveOrEdit, getAssetInfo } from '@/api/ledgerAssets';
  501. import { getUserPage } from '@/api/system/organization';
  502. export default {
  503. components: {
  504. //selectUpload,
  505. //UploadImg,
  506. FactoryLineSelect,
  507. WithView,
  508. WorkshopSelect,
  509. FactoryAreaSelect,
  510. WorkingProcedureSelect,
  511. fileUpload,
  512. imgUpload,
  513. factorySelect,
  514. DialogGoods,
  515. DeptSelect
  516. },
  517. data () {
  518. return {
  519. title: '新建设备信息',
  520. pageType: 'add',
  521. btnLoading: false,
  522. // 设备主键id
  523. id: '',
  524. form: {
  525. extInfoSelf: [],
  526. // 基本信息
  527. code: '',
  528. name: '',
  529. productTime: ''
  530. },
  531. rules: {
  532. name: [
  533. { required: true, message: '请输入设备名称', trigger: 'blur' }
  534. ],
  535. code: [{ required: true, message: '请输入设备编码', trigger: 'blur' }]
  536. },
  537. // 基本信息
  538. basicInfo: {},
  539. assetInfo:{},
  540. // 资产信息
  541. zcInfo: {
  542. // 固定资产编码
  543. fixCode: '',
  544. // 颜色
  545. color: '',
  546. // 重量
  547. weight: '',
  548. // 维护部门code
  549. repairGroupId: '',
  550. repairDeptName: '',
  551. repairUserId: '',
  552. // 权属部门
  553. ownershipGroupId: '',
  554. ownershipUserId: '',
  555. // 设备用途
  556. purpose: '',
  557. // 工序
  558. roteId: '',
  559. //品牌
  560. brand: '',
  561. // 供应商code
  562. supplierId: '',
  563. // 厂房
  564. factoryRoomId: '',
  565. roteCode: ''
  566. },
  567. positionInfo: {
  568. // 详细地址
  569. detailPosition: '',
  570. // 请选择产线
  571. lineCode: '',
  572. lineName: '',
  573. // 请选择车间
  574. workshopCode: '',
  575. workshopName: '',
  576. // 请选择工厂
  577. factoryCode: '',
  578. factoryName: ''
  579. },
  580. // 图片
  581. imageUrl: null,
  582. // 文档信息
  583. attUrl: {
  584. operatingManual: {
  585. value: [],
  586. sort: 1
  587. },
  588. productionLicence: {
  589. value: [],
  590. sort: 2
  591. },
  592. explosionProofCertificate: {
  593. value: [],
  594. sort: 3
  595. },
  596. surveyReport: {
  597. value: [],
  598. sort: 4
  599. },
  600. inspectionCycleManual: {
  601. value: [],
  602. sort: 5
  603. },
  604. informationDrawing: {
  605. value: [],
  606. sort: 6
  607. },
  608. productCertificate: {
  609. value: [],
  610. sort: 7
  611. }
  612. },
  613. // 是否开始物联
  614. isIotEnable: true,
  615. // 物联ID
  616. iotId: '',
  617. // 回显过保时间
  618. cbexpirationTime: '',
  619. // 生命周期
  620. sourceDICT: '',
  621. // 网络状态
  622. networkStatus: '',
  623. options: {
  624. deptList: [],
  625. repairUserId: [],
  626. ownershipUserId: [],
  627. supplierId: [],
  628. brand: []
  629. }
  630. };
  631. },
  632. watch: {},
  633. computed: {
  634. // 过保时间
  635. expirationTime () {
  636. if (this.form.productTime && this.basicInfo.expirationDate) {
  637. return this.setGbTime(
  638. this.form.productTime,
  639. this.basicInfo.expirationDate,
  640. this.basicInfo.expirationDateUnit
  641. );
  642. } else {
  643. return '';
  644. }
  645. }
  646. },
  647. created () {
  648. if (this.$route.query.id) {
  649. this.pageType = 'edit';
  650. this.id = this.$route.query.id;
  651. this.getInfo();
  652. this.title = '编辑设备信息';
  653. }
  654. },
  655. methods: {
  656. handlwpbm () {
  657. this.$refs.DialogGoods.open();
  658. },
  659. async cbDialogGoods (data) {
  660. this.basicInfo = data;
  661. this.assetInfo = data
  662. this.form.rootCategoryLevelId = this.basicInfo.categoryLevelPathId.split(',')[0];
  663. this.form.categoryId = this.basicInfo.id;
  664. this.form.name = this.basicInfo.name;
  665. // let res = await getAssetNum({
  666. // assetCode: this.basicInfo.code,
  667. // num: 1
  668. // });
  669. this.form.code = Date.now(); //res.data[0].onlyCode;
  670. },
  671. // 计算过保时间
  672. setGbTime (basic, value, type) {
  673. basic = Date.parse(basic);
  674. let time;
  675. switch (type) {
  676. case 'minute':
  677. time = value * 1000 * 60;
  678. break;
  679. case 'hour':
  680. time = value * 1000 * 60 * 60;
  681. break;
  682. case 'day':
  683. time = value * 1000 * 60 * 60 * 24;
  684. break;
  685. case 'month':
  686. time = value * 1000 * 60 * 60 * 24 * 30;
  687. break;
  688. case 'year':
  689. time = value * 1000 * 60 * 60 * 24 * 365;
  690. break;
  691. default:
  692. break;
  693. }
  694. let num = basic + time;
  695. return parseTime(num);
  696. },
  697. async getwhbm () {
  698. if (!this.zcInfo.repairGroupId) return;
  699. let data = await getUserPage({
  700. pageNum: 1,
  701. size: 9999,
  702. groupId: this.zcInfo.repairGroupId
  703. });
  704. this.options.repairUserId = data.list;
  705. },
  706. async getqsbm () {
  707. if (!this.zcInfo.ownershipGroupId) return;
  708. let data = await getUserPage({
  709. pageNum: 1,
  710. size: 9999,
  711. groupId: this.zcInfo.ownershipGroupId
  712. });
  713. this.options.ownershipUserId = data.list;
  714. },
  715. // 树形结构数据
  716. getTreeList () {
  717. org.tree().then((res) => {
  718. this.options.deptList = res.data;
  719. });
  720. },
  721. // 获取供应商、工序列表
  722. async getgys () {
  723. let muster = await getSupplier({
  724. size: 999
  725. });
  726. this.options.supplierId = muster.data.items; //供应商
  727. },
  728. // 添加自定义参数
  729. addItem () {
  730. if (this.form.extInfoSelf.length < 10) {
  731. let item = { key: '', value: '' };
  732. this.form.extInfoSelf.push(item);
  733. } else {
  734. this.$message.warning('自定义参数最多添加10条');
  735. }
  736. },
  737. // 删除自定义参数
  738. delt (item, index) {
  739. this.form.extInfoSelf.splice(index, 1);
  740. },
  741. // 提交
  742. submit () {
  743. if (!this.basicInfo && this.pageType == 'add') {
  744. return this.$message.error('请选择物品编码');
  745. }
  746. this.$refs.form.validate((valid) => {
  747. if (valid) {
  748. let par = {
  749. //基本信息
  750. ...this.form,
  751. // id: this.basicInfo.id,
  752. // assetCode: this.form.code,
  753. // assetName: this.form.name,
  754. assetType: 1,
  755. // informationId: this.basicInfo.id,
  756. // productTime: this.form.productTime,
  757. // expirationTime: this.expirationTime,
  758. // 资产信息
  759. positionIds: '1,1,1,1',
  760. ...this.zcInfo,
  761. position: {
  762. detailPosition: this.positionInfo.detailPosition,
  763. pathIds: `${this.positionInfo.factoryCode},${this.positionInfo.workshopCode},${this.positionInfo.lineCode}`,
  764. pathName: `${this.positionInfo.factoryName},${this.positionInfo.workshopName},${this.positionInfo.lineName}`,
  765. type: 'PRODUCTION_LINE',
  766. num: 1
  767. },
  768. // 文档信息
  769. attUrl: this.setWd() || [],
  770. // // 设备图片
  771. imageUrl: this.imageUrl || {},
  772. // 是否启用物联
  773. isIotEnable: this.isIotEnable
  774. // // 扩展字段
  775. // extInfoSelf: this.setKz()
  776. };
  777. if (this.pageType == 'edit') {
  778. par.id = this.id;
  779. }
  780. this.btnLoading = true;
  781. saveOrEdit(par)
  782. .then((res) => {
  783. this.$message.success('操作成功');
  784. this.$router.go(-1);
  785. })
  786. .finally(() => {
  787. this.btnLoading = false;
  788. });
  789. } else {
  790. console.log('error submit!!');
  791. return false;
  792. }
  793. });
  794. },
  795. // 处理扩展字段
  796. setKz () {
  797. return this.form.extInfoSelf || [];
  798. },
  799. // 处理文档信息
  800. setWd () {
  801. return Object.values(this.attUrl).map((item) => ({
  802. ...(item.value[0] || {}),
  803. sort: item.sort
  804. }));
  805. },
  806. // 获取设备详情
  807. async getInfo () {
  808. const data = await getAssetInfo(this.id);
  809. data.extInfoSelf = data.extInfoSelf || [];
  810. this.form = data;
  811. this.basicInfo = data.category;
  812. this.assetInfo = data.category.category;
  813. this.cbexpirationTime = data.expirationTime;
  814. this.sourceDICT = data.sourceDICT;
  815. this.networkStatus = data.networkStatus;
  816. if (data.positionList?.length) {
  817. this.positionInfo.detailPosition =
  818. data.positionList[0].detailPosition;
  819. const pathIds = data.positionList[0].pathIds.split(',');
  820. const pathName = data.positionList[0].pathName.split(',');
  821. this.positionInfo.factoryCode = pathIds[0];
  822. this.positionInfo.factoryName = pathName[0];
  823. this.positionInfo.workshopCode = pathIds[1];
  824. this.positionInfo.workshopName = pathName[1];
  825. this.positionInfo.lineCode = pathIds[2];
  826. this.positionInfo.lineName = pathName[2];
  827. this.$nextTick(() => {
  828. this.$refs.WorkshopSelectRef.getList();
  829. this.$refs.FactoryLineSelectRef.getList();
  830. });
  831. }
  832. // 资产信息
  833. for (const key of Object.keys(this.zcInfo)) {
  834. this.zcInfo[key] = data[key];
  835. }
  836. this.getwhbm();
  837. this.getqsbm();
  838. if (data.attUrl && data.attUrl.length > 0) {
  839. // 文档信息
  840. Object.keys(this.attUrl).forEach((n, index) => {
  841. this.attUrl[n].value =
  842. (data.attUrl[index]?.storePath && [data.attUrl[index]]) || [];
  843. });
  844. }
  845. // 设备图片
  846. this.imageUrl = data.imageUrl;
  847. // 物联参数
  848. this.isIotEnable = data.isIotEnable;
  849. this.iotId = data.iotId;
  850. },
  851. // 设置标准产能
  852. setbzcn (val) {
  853. if (!val) {
  854. return '';
  855. }
  856. let item = JSON.parse(val);
  857. return item.standardCapacity || '';
  858. },
  859. hanldFactoryCode (val, item) {
  860. this.positionInfo.factoryName = item?.name;
  861. // 重置
  862. this.zcInfo.workshopCode = '';
  863. this.zcInfo.lineCode = '';
  864. this.options.workshopCode = [];
  865. this.options.lineCode = [];
  866. // 获取车间
  867. this.$nextTick(() => {
  868. this.$refs.WorkshopSelectRef.getList();
  869. });
  870. },
  871. hanldWorkshopCode (val, item) {
  872. this.positionInfo.workshopName = item?.name;
  873. // 重置
  874. this.options.workshopCode = [];
  875. this.options.lineCode = [];
  876. // 获取产线
  877. this.$nextTick(() => {
  878. this.$refs.FactoryLineSelectRef.getList();
  879. });
  880. },
  881. hanldlineCodeCode (val, item) {
  882. this.positionInfo.lineName = item?.name;
  883. }
  884. }
  885. };
  886. </script>
  887. <style lang="scss" scoped>
  888. .baseinfo-container .basic-details-title {
  889. font-size: 16px;
  890. margin: 15px 0;
  891. }
  892. .upload-container {
  893. display: flex;
  894. justify-content: flex-start;
  895. .file-list {
  896. margin-left: 50px;
  897. flex: 1;
  898. }
  899. }
  900. .equipment-container {
  901. // .content {
  902. // padding: 0 20px;
  903. // }
  904. .label-none {
  905. .el-form-item__content {
  906. margin-left: 0 !important;
  907. }
  908. }
  909. }
  910. .sbwz {
  911. .item {
  912. width: 120px !important;
  913. }
  914. .item + .item {
  915. margin-left: 10px;
  916. }
  917. .item-input {
  918. width: 350px !important;
  919. }
  920. }
  921. .input {
  922. width: 202px;
  923. }
  924. .kzzd {
  925. width: 500px;
  926. .add-col {
  927. display: flex;
  928. .col-input {
  929. & + .col-input {
  930. margin-left: 10px;
  931. }
  932. }
  933. .del {
  934. margin-left: 10px;
  935. }
  936. }
  937. }
  938. </style>