index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="装置" prop="plant">
  5. <el-input
  6. v-model="queryParams.plant"
  7. placeholder="请输入装置"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="位置" prop="devLoc">
  14. <el-input
  15. v-model="queryParams.devLoc"
  16. placeholder="请输入位置"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="设备名称" prop="devName">
  23. <el-input
  24. v-model="queryParams.devName"
  25. placeholder="请输入设备名称"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="设备位号" prop="devTag">
  32. <el-input
  33. v-model="queryParams.devTag"
  34. placeholder="请输入设备位号"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="设备类型" prop="devType">
  41. <el-select v-model="queryParams.devType" placeholder="请选择设备类型" clearable size="small">
  42. <el-option label="请选择字典生成" value="" />
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item label="设备描述" prop="devDesc">
  46. <el-input
  47. v-model="queryParams.devDesc"
  48. placeholder="请输入设备描述"
  49. clearable
  50. size="small"
  51. @keyup.enter.native="handleQuery"
  52. />
  53. </el-form-item>
  54. <el-form-item label="区域" prop="devArea">
  55. <el-input
  56. v-model="queryParams.devArea"
  57. placeholder="请输入区域"
  58. clearable
  59. size="small"
  60. @keyup.enter.native="handleQuery"
  61. />
  62. </el-form-item>
  63. <el-form-item label="备注" prop="remarks">
  64. <el-input
  65. v-model="queryParams.remarks"
  66. placeholder="请输入备注"
  67. clearable
  68. size="small"
  69. @keyup.enter.native="handleQuery"
  70. />
  71. </el-form-item>
  72. <el-form-item>
  73. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  74. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  75. </el-form-item>
  76. </el-form>
  77. <el-row :gutter="10" class="mb8">
  78. <el-col :span="1.5">
  79. <el-button
  80. type="primary"
  81. icon="el-icon-plus"
  82. size="mini"
  83. @click="handleAdd"
  84. v-hasPermi="['reliability:rel_device:add']"
  85. >新增</el-button>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-button
  89. type="success"
  90. icon="el-icon-edit"
  91. size="mini"
  92. :disabled="single"
  93. @click="handleUpdate"
  94. v-hasPermi="['reliability:rel_device:edit']"
  95. >修改</el-button>
  96. </el-col>
  97. <el-col :span="1.5">
  98. <el-button
  99. type="danger"
  100. icon="el-icon-delete"
  101. size="mini"
  102. :disabled="multiple"
  103. @click="handleDelete"
  104. v-hasPermi="['reliability:rel_device:remove']"
  105. >删除</el-button>
  106. </el-col>
  107. <el-col :span="1.5">
  108. <el-button
  109. type="info"
  110. icon="el-icon-upload2"
  111. size="mini"
  112. @click="handleImport"
  113. v-hasPermi="['reliability:rel_device:edit']"
  114. >导入</el-button>
  115. </el-col>
  116. <el-col :span="1.5">
  117. <el-button
  118. type="warning"
  119. icon="el-icon-download"
  120. size="mini"
  121. @click="handleExport"
  122. v-hasPermi="['reliability:rel_device:list']"
  123. >导出</el-button>
  124. </el-col>
  125. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  126. </el-row>
  127. <el-table v-loading="loading" :data="rel_deviceList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  128. <el-table-column type="selection" width="55" align="center" />
  129. <el-table-column label="装置" align="center" prop="plant" width="120" :show-overflow-tooltip="true"/>
  130. <el-table-column label="位置" align="center" prop="devLoc" width="120" :show-overflow-tooltip="true"/>
  131. <el-table-column label="设备名称" align="center" prop="devName" width="150" :show-overflow-tooltip="true">
  132. <template slot-scope="scope">
  133. <el-button type="text" @click="handleDeviceDetail(scope.row)">
  134. {{ scope.row.devName }}
  135. </el-button>
  136. </template>
  137. </el-table-column>
  138. <el-table-column label="设备位号" align="center" prop="devTag" width="150" :show-overflow-tooltip="true"/>
  139. <el-table-column label="设备类型" align="center" prop="devType" width="120" :show-overflow-tooltip="true"/>
  140. <el-table-column label="设备描述" align="center" prop="devDesc" width="180" :show-overflow-tooltip="true"/>
  141. <el-table-column label="区域" align="center" prop="devArea" width="120" :show-overflow-tooltip="true"/>
  142. <el-table-column label="区域负责人" align="center" prop="areaResponsible" width="120" :show-overflow-tooltip="true">
  143. <template slot-scope="scope">
  144. {{ scope.row.areaResponsibleName || getStaffName(scope.row.areaResponsible) }}
  145. </template>
  146. </el-table-column>
  147. <el-table-column label="设备照片" align="center" prop="devPhoto" width="100">
  148. <template slot-scope="scope">
  149. <el-button
  150. v-if="scope.row.devPhoto"
  151. size="mini"
  152. type="text"
  153. icon="el-icon-picture"
  154. @click="handleViewPhoto(scope.row.devPhoto)">
  155. 查看
  156. </el-button>
  157. <span v-else>-</span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column label="备注" align="center" prop="remarks" width="150" :show-overflow-tooltip="true"/>
  161. <el-table-column label="操作" align="center" fixed="right" width="180" class-name="small-padding fixed-width">
  162. <template slot-scope="scope">
  163. <el-button
  164. size="mini"
  165. type="text"
  166. icon="el-icon-plus"
  167. @click="handleAddPlan(scope.row)"
  168. v-hasPermi="['reliability:rel_maint_plan:add']"
  169. >新计划</el-button>
  170. <el-button
  171. size="mini"
  172. type="text"
  173. icon="el-icon-edit"
  174. @click="handleUpdate(scope.row)"
  175. v-hasPermi="['reliability:rel_device:edit']"
  176. >修改</el-button>
  177. <el-button
  178. size="mini"
  179. type="text"
  180. icon="el-icon-delete"
  181. @click="handleDelete(scope.row)"
  182. v-hasPermi="['reliability:rel_device:remove']"
  183. >删除</el-button>
  184. </template>
  185. </el-table-column>
  186. </el-table>
  187. <pagination
  188. v-show="total>0"
  189. :total="total"
  190. :page.sync="queryParams.pageNum"
  191. :limit.sync="queryParams.pageSize"
  192. @pagination="getList"
  193. />
  194. <!-- 添加或修改可靠性设备清单对话框 -->
  195. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  196. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  197. <el-form-item label="装置" prop="plant">
  198. <el-input v-model="form.plant" placeholder="请输入装置" />
  199. </el-form-item>
  200. <el-form-item label="位置" prop="devLoc">
  201. <el-input v-model="form.devLoc" placeholder="请输入位置" />
  202. </el-form-item>
  203. <el-form-item label="设备名称" prop="devName">
  204. <el-input v-model="form.devName" placeholder="请输入设备名称" />
  205. </el-form-item>
  206. <el-form-item label="设备位号" prop="devTag">
  207. <el-input v-model="form.devTag" placeholder="请输入设备位号" />
  208. </el-form-item>
  209. <el-form-item label="设备类型" prop="devType">
  210. <el-input v-model="form.devType" placeholder="请输入设备类型" />
  211. </el-form-item>
  212. <el-form-item label="设备描述" prop="devDesc">
  213. <el-input v-model="form.devDesc" placeholder="请输入设备描述" />
  214. </el-form-item>
  215. <el-form-item label="区域" prop="devArea">
  216. <el-input v-model="form.devArea" placeholder="请输入区域" />
  217. </el-form-item>
  218. <el-form-item label="区域负责人" prop="areaResponsible">
  219. <el-select v-model="form.areaResponsible" placeholder="请选择区域负责人" clearable filterable>
  220. <el-option
  221. v-for="staff in staffOptions"
  222. :key="staff.id"
  223. :label="staff.name"
  224. :value="staff.staffid">
  225. </el-option>
  226. </el-select>
  227. </el-form-item>
  228. <el-form-item label="设备照片" prop="devPhoto">
  229. <el-upload
  230. class="upload-demo"
  231. :action="uploadPhoto.url"
  232. :headers="uploadPhoto.headers"
  233. :data="uploadPhoto.data"
  234. :on-success="handlePhotoSuccess"
  235. :on-remove="handleRemovePhoto"
  236. :before-upload="beforePhotoUpload"
  237. :file-list="photoFileList"
  238. :limit="1"
  239. list-type="picture-card"
  240. :on-exceed="handleExceedPhoto"
  241. accept="image/*">
  242. <i class="el-icon-plus"></i>
  243. <div slot="tip" class="el-upload__tip">只能上传jpg/png/gif文件,且不超过15MB</div>
  244. </el-upload>
  245. </el-form-item>
  246. </el-form>
  247. <div slot="footer" class="dialog-footer">
  248. <el-button type="primary" @click="submitForm">确 定</el-button>
  249. <el-button @click="cancel">取 消</el-button>
  250. </div>
  251. </el-dialog>
  252. <!-- 用户导入对话框 -->
  253. <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  254. <el-upload
  255. ref="upload"
  256. :limit="1"
  257. accept=".xlsx, .xls"
  258. :headers="upload.headers"
  259. :action="upload.url + '?updateSupport=1'"
  260. :disabled="upload.isUploading"
  261. :on-progress="handleFileUploadProgress"
  262. :on-success="handleFileSuccess"
  263. :auto-upload="false"
  264. drag
  265. >
  266. <i class="el-icon-upload"></i>
  267. <div class="el-upload__text">
  268. 将文件拖到此处,或
  269. <em>点击上传</em>
  270. </div>
  271. <div class="el-upload__tip" slot="tip">
  272. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  273. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  274. <input name="type" :value="upload.type" hidden/>
  275. </form>
  276. </div>
  277. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  278. </el-upload>
  279. <div slot="footer" class="dialog-footer">
  280. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  281. <el-button @click="upload.open = false">取 消</el-button>
  282. </div>
  283. </el-dialog>
  284. <!-- 图片预览对话框 -->
  285. <el-dialog title="查看照片" :visible.sync="photoPreviewVisible" width="800px" append-to-body>
  286. <div class="photo-preview-container">
  287. <img :src="previewPhotoUrl" alt="设备照片" style="width: 100%; height: auto;">
  288. </div>
  289. </el-dialog>
  290. <!-- 维修计划表单对话框 -->
  291. <maint-plan-form
  292. :visible.sync="maintPlanFormOpen"
  293. :title="maintPlanFormTitle"
  294. :form="maintPlanFormData"
  295. @submit="handleMaintPlanFormSubmit"
  296. @cancel="handleMaintPlanFormCancel"
  297. />
  298. </div>
  299. </template>
  300. <script>
  301. import { listRel_device, getRel_device, delRel_device, addRel_device, updateRel_device, exportRel_device, importTemplate} from "@/api/reliability/rel_device";
  302. import { treeselect } from "@/api/system/dept";
  303. import { listStaffmgrAll } from "@/api/plant/staffmgr";
  304. import { getToken } from "@/utils/auth";
  305. import Treeselect from "@riophae/vue-treeselect";
  306. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  307. import MaintPlanForm from "@/views/reliability/rel_maint_plan/MaintPlanForm.vue";
  308. export default {
  309. name: "Rel_device",
  310. components: { Treeselect, MaintPlanForm },
  311. data() {
  312. return {
  313. // 遮罩层
  314. loading: true,
  315. // 选中数组
  316. ids: [],
  317. // 非单个禁用
  318. single: true,
  319. // 非多个禁用
  320. multiple: true,
  321. // 显示搜索条件
  322. showSearch: false,
  323. // 总条数
  324. total: 0,
  325. // 可靠性设备清单表格数据
  326. rel_deviceList: [],
  327. // 弹出层标题
  328. title: "",
  329. // 部门树选项
  330. deptOptions: undefined,
  331. // 人员列表选项
  332. staffOptions: [],
  333. clientHeight:300,
  334. // 是否显示弹出层
  335. open: false,
  336. // 用户导入参数
  337. upload: {
  338. //下载模板请求地址
  339. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  340. //下载模板类型
  341. type: 'rel_device',
  342. // 是否显示弹出层(用户导入)
  343. open: false,
  344. // 弹出层标题(用户导入)
  345. title: "",
  346. // 是否禁用上传
  347. isUploading: false,
  348. // 设置上传的请求头部
  349. headers: { Authorization: "Bearer " + getToken() },
  350. // 上传的地址
  351. url: process.env.VUE_APP_BASE_API + "/reliability/rel_device/importData"
  352. },
  353. // 设备照片上传参数
  354. uploadPhoto: {
  355. // 设置上传的请求头部
  356. headers: { Authorization: "Bearer " + getToken() },
  357. // 上传的地址(使用支持自定义路径的接口)
  358. url: process.env.VUE_APP_BASE_API + "/common/uploadWithPath",
  359. // 上传路径参数
  360. data: { path: "/rel/dev" }
  361. },
  362. // 设备照片文件列表
  363. photoFileList: [],
  364. // 图片预览相关
  365. photoPreviewVisible: false,
  366. previewPhotoUrl: '',
  367. // 维修计划表单相关
  368. maintPlanFormOpen: false,
  369. maintPlanFormTitle: "",
  370. maintPlanFormData: {},
  371. // 查询参数
  372. queryParams: {
  373. pageNum: 1,
  374. pageSize: 20,
  375. plant: null,
  376. devLoc: null,
  377. devName: null,
  378. devTag: null,
  379. devType: null,
  380. devDesc: null,
  381. devArea: null,
  382. areaResponsible: null,
  383. devPhoto: null,
  384. createrCode: null,
  385. createdate: null,
  386. updaterCode: null,
  387. updatedate: null,
  388. deptId: null,
  389. remarks: null
  390. },
  391. // 表单参数
  392. form: {},
  393. // 表单校验
  394. rules: {
  395. devTag: [
  396. { required: true, message: "设备位号不能为空", trigger: "blur" }
  397. ],
  398. }
  399. };
  400. },
  401. watch: {
  402. // 根据名称筛选部门树
  403. deptName(val) {
  404. this.$refs.tree.filter(val);
  405. }
  406. },
  407. created() {
  408. //设置表格高度对应屏幕高度
  409. this.$nextTick(() => {
  410. this.clientHeight = document.body.clientHeight -250
  411. })
  412. this.getList();
  413. this.getTreeselect();
  414. this.getStaffList();
  415. },
  416. methods: {
  417. /** 查询可靠性设备清单列表 */
  418. getList() {
  419. this.loading = true;
  420. listRel_device(this.queryParams).then(response => {
  421. this.rel_deviceList = response.rows;
  422. this.total = response.total;
  423. this.loading = false;
  424. });
  425. },
  426. /** 查询部门下拉树结构 */
  427. getTreeselect() {
  428. treeselect().then(response => {
  429. this.deptOptions = response.data;
  430. });
  431. },
  432. /** 查询人员列表 */
  433. getStaffList() {
  434. listStaffmgrAll().then(response => {
  435. this.staffOptions = response.rows || response.data || [];
  436. });
  437. },
  438. // 取消按钮
  439. cancel() {
  440. this.open = false;
  441. this.reset();
  442. },
  443. // 表单重置
  444. reset() {
  445. this.form = {
  446. devId: null,
  447. plant: null,
  448. devLoc: null,
  449. devName: null,
  450. devTag: null,
  451. devType: null,
  452. devDesc: null,
  453. devArea: null,
  454. areaResponsible: null,
  455. devPhoto: null,
  456. delFlag: null,
  457. createrCode: null,
  458. createdate: null,
  459. updaterCode: null,
  460. updatedate: null,
  461. deptId: null,
  462. remarks: null
  463. };
  464. this.photoFileList = [];
  465. this.resetForm("form");
  466. },
  467. /** 搜索按钮操作 */
  468. handleQuery() {
  469. this.queryParams.pageNum = 1;
  470. this.getList();
  471. },
  472. /** 重置按钮操作 */
  473. resetQuery() {
  474. this.resetForm("queryForm");
  475. this.handleQuery();
  476. },
  477. // 多选框选中数据
  478. handleSelectionChange(selection) {
  479. this.ids = selection.map(item => item.devId)
  480. this.single = selection.length!==1
  481. this.multiple = !selection.length
  482. },
  483. /** 新增按钮操作 */
  484. handleAdd() {
  485. this.reset();
  486. this.open = true;
  487. this.title = "添加可靠性设备清单";
  488. },
  489. /** 修改按钮操作 */
  490. handleUpdate(row) {
  491. this.reset();
  492. const devId = row.devId || this.ids
  493. getRel_device(devId).then(response => {
  494. this.form = response.data;
  495. // 如果有照片,加载到文件列表
  496. if (this.form.devPhoto) {
  497. // 如果是相对路径,需要拼接完整URL
  498. let imageUrl = this.form.devPhoto;
  499. if (imageUrl && !imageUrl.startsWith('http')) {
  500. imageUrl = process.env.VUE_APP_BASE_API + imageUrl;
  501. }
  502. this.photoFileList = [{
  503. name: '设备照片',
  504. url: imageUrl
  505. }];
  506. console.log('加载图片URL:', imageUrl);
  507. }
  508. this.open = true;
  509. this.title = "修改可靠性设备清单";
  510. });
  511. },
  512. /** 提交按钮 */
  513. submitForm() {
  514. this.$refs["form"].validate(valid => {
  515. if (valid) {
  516. // 调试:打印表单数据
  517. console.log('提交表单数据:', this.form);
  518. console.log('设备照片路径:', this.form.devPhoto);
  519. if (this.form.devId != null) {
  520. updateRel_device(this.form).then(response => {
  521. this.msgSuccess("修改成功");
  522. this.open = false;
  523. this.getList();
  524. });
  525. } else {
  526. addRel_device(this.form).then(response => {
  527. this.msgSuccess("新增成功");
  528. this.open = false;
  529. this.getList();
  530. });
  531. }
  532. }
  533. });
  534. },
  535. /** 删除按钮操作 */
  536. handleDelete(row) {
  537. const devIds = row.devId || this.ids;
  538. this.$confirm('是否确认删除?', "警告", {
  539. confirmButtonText: "确定",
  540. cancelButtonText: "取消",
  541. type: "warning"
  542. }).then(function() {
  543. return delRel_device(devIds);
  544. }).then(() => {
  545. this.getList();
  546. this.msgSuccess("删除成功");
  547. })
  548. },
  549. /** 导出按钮操作 */
  550. handleExport() {
  551. const queryParams = this.queryParams;
  552. this.$confirm('是否确认导出所有可靠性设备清单数据项?', "警告", {
  553. confirmButtonText: "确定",
  554. cancelButtonText: "取消",
  555. type: "warning"
  556. }).then(function() {
  557. return exportRel_device(queryParams);
  558. }).then(response => {
  559. this.download(response.msg);
  560. })
  561. },
  562. /** 导入按钮操作 */
  563. handleImport() {
  564. this.upload.title = "用户导入";
  565. this.upload.open = true;
  566. },
  567. /** 下载模板操作 */
  568. importTemplate() {
  569. this.$refs['downloadFileForm'].submit()
  570. },
  571. // 文件上传中处理
  572. handleFileUploadProgress(event, file, fileList) {
  573. this.upload.isUploading = true;
  574. },
  575. // 文件上传成功处理
  576. handleFileSuccess(response, file, fileList) {
  577. this.upload.open = false;
  578. this.upload.isUploading = false;
  579. this.$refs.upload.clearFiles();
  580. this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
  581. this.getList();
  582. },
  583. // 提交上传文件
  584. submitFileForm() {
  585. this.$refs.upload.submit();
  586. },
  587. /** 设备详情按钮操作 */
  588. handleDeviceDetail(row) {
  589. // 跳转到设备详情页面
  590. this.$router.push({
  591. path: '/reliability/rel_device/detail',
  592. query: { deviceId: row.devId }
  593. });
  594. },
  595. /** 上传前的校验 */
  596. beforePhotoUpload(file) {
  597. const isImage = file.type.startsWith('image/');
  598. const isLt15M = file.size / 1024 / 1024 < 15;
  599. if (!isImage) {
  600. this.$message.error('只能上传图片文件!');
  601. return false;
  602. }
  603. if (!isLt15M) {
  604. this.$message.error('上传图片大小不能超过 15MB!');
  605. return false;
  606. }
  607. return true;
  608. },
  609. /** 图片上传成功回调 */
  610. handlePhotoSuccess(response, file, fileList) {
  611. console.log('上传接口返回数据:', response);
  612. // 若依框架上传接口返回格式
  613. if (response && response.fileName) {
  614. // 保存文件路径到表单(相对路径)
  615. this.form.devPhoto = response.fileName;
  616. // 构建完整URL用于预览
  617. let imageUrl = response.url || response.fileName;
  618. if (imageUrl && !imageUrl.startsWith('http')) {
  619. imageUrl = process.env.VUE_APP_BASE_API + imageUrl;
  620. }
  621. this.photoFileList = [{
  622. name: file.name,
  623. url: imageUrl
  624. }];
  625. console.log('图片路径已保存到 form.devPhoto:', this.form.devPhoto);
  626. console.log('预览URL:', imageUrl);
  627. this.$message.success('上传成功');
  628. } else {
  629. console.error('上传返回数据格式不正确:', response);
  630. this.$message.error(response.msg || '上传失败');
  631. }
  632. },
  633. /** 删除图片 */
  634. handleRemovePhoto(file, fileList) {
  635. this.form.devPhoto = null;
  636. this.photoFileList = [];
  637. },
  638. /** 超出文件个数限制 */
  639. handleExceedPhoto(files, fileList) {
  640. this.$message.warning('只能上传1张图片');
  641. },
  642. /** 查看图片 */
  643. handleViewPhoto(photoPath) {
  644. if (photoPath) {
  645. // 如果是相对路径,拼接完整URL
  646. let imageUrl = photoPath;
  647. if (imageUrl && !imageUrl.startsWith('http')) {
  648. imageUrl = process.env.VUE_APP_BASE_API + imageUrl;
  649. }
  650. this.previewPhotoUrl = imageUrl;
  651. this.photoPreviewVisible = true;
  652. }
  653. },
  654. /** 新增维修计划按钮操作 */
  655. handleAddPlan(row) {
  656. // 初始化维修计划表单数据,预填设备信息
  657. this.maintPlanFormData = {
  658. planId: null,
  659. devId: row.devId,
  660. plant: row.plant,
  661. devName: row.devName,
  662. devTag: row.devTag,
  663. planTime: null,
  664. approvalStatus: "0",
  665. responsible: null,
  666. completionStatus: "0",
  667. processId: null,
  668. approver: null,
  669. delFlag: null,
  670. createrCode: null,
  671. createdate: null,
  672. updaterCode: null,
  673. updatedate: null,
  674. deptId: null,
  675. remarks: null,
  676. maintComponents: []
  677. };
  678. this.maintPlanFormTitle = "添加设备维修计划";
  679. this.maintPlanFormOpen = true;
  680. },
  681. /** 维修计划表单提交 */
  682. handleMaintPlanFormSubmit(formData) {
  683. // 这里可以处理维修计划表单提交后的逻辑
  684. // 例如刷新列表等
  685. this.getList();
  686. },
  687. /** 维修计划表单取消 */
  688. handleMaintPlanFormCancel() {
  689. this.maintPlanFormOpen = false;
  690. this.maintPlanFormData = {};
  691. },
  692. /** 根据人员ID获取人员姓名 */
  693. getStaffName(staffId) {
  694. if (!staffId) return '-';
  695. const staff = this.staffOptions.find(s => s.staffid === staffId);
  696. return staff ? staff.name : staffId;
  697. }
  698. }
  699. };
  700. </script>
  701. <style scoped>
  702. .upload-demo >>> .el-upload--picture-card {
  703. width: 148px;
  704. height: 148px;
  705. line-height: 148px;
  706. }
  707. .upload-demo >>> .el-upload-list--picture-card .el-upload-list__item {
  708. width: 148px;
  709. height: 148px;
  710. }
  711. </style>