edit.vue 31 KB

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