draught.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. <template>
  2. <div class="global-variable" v-loading="loading">
  3. <div class="condition">
  4. <el-form :inline="true" :model="formInline" class="demo-form-inline">
  5. <el-form-item label="风机名称:">
  6. <el-input
  7. v-model="formInline.engineName"
  8. placeholder="请输入风机名称"
  9. size="small"
  10. ></el-input>
  11. </el-form-item>
  12. <el-form-item label="选择日期:" size="small">
  13. <el-date-picker
  14. v-model="formInline.timeQuantum"
  15. type="daterange"
  16. range-separator="至"
  17. start-placeholder="开始日期"
  18. end-placeholder="结束日期"
  19. @change="onDateChange"
  20. >
  21. </el-date-picker>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button type="primary" @click="onSubmit" size="small"
  25. >查询</el-button
  26. >
  27. <el-button @click="reset" size="small">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. <div class="list-page">
  32. <div class="newly">
  33. <el-button @click="upfile" size="small">导入</el-button>
  34. <el-button type="primary" @click="newnuedialog" size="small"
  35. >新增</el-button
  36. >
  37. </div>
  38. <el-table
  39. class="center-align-table"
  40. :data="tableData"
  41. border
  42. :cell-style="rowStyle"
  43. >
  44. <el-table-column
  45. align="center"
  46. fixed
  47. prop="engineCode"
  48. label="系统编号"
  49. >
  50. <template slot-scope="scope">
  51. <el-button
  52. @click="particulars(scope.row)"
  53. type="text"
  54. size="small"
  55. >{{ scope.row.engineCode }}</el-button
  56. >
  57. </template>
  58. </el-table-column>
  59. <el-table-column prop="engineName" align="center" label="风机名称">
  60. </el-table-column>
  61. <el-table-column prop="fieldName" align="center" label="关联风场">
  62. </el-table-column>
  63. <el-table-column
  64. prop="longitude"
  65. align="center"
  66. label="经度"
  67. width="100"
  68. >
  69. </el-table-column>
  70. <el-table-column
  71. prop="latitude"
  72. align="center"
  73. label="纬度"
  74. width="100"
  75. >
  76. </el-table-column>
  77. <el-table-column
  78. prop="elevationHeight"
  79. align="center"
  80. label="海拔高度/米"
  81. width="100"
  82. >
  83. </el-table-column>
  84. <el-table-column
  85. prop="sightcing"
  86. align="center"
  87. label="是否标杆"
  88. width="80"
  89. >
  90. <template slot-scope="{ row }">
  91. {{ row.sightcing == 1 ? "是" : "否" }}
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="state" align="center" label="状态" width="80">
  95. <template slot-scope="{ row }">
  96. {{ row.state == 1 ? "启用" : "停用" }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. prop="createTime"
  101. align="center"
  102. label="创建时间"
  103. width="140"
  104. >
  105. </el-table-column>
  106. <el-table-column
  107. prop="transition"
  108. align="center"
  109. fixed="right"
  110. label="操作"
  111. width="160"
  112. >
  113. <template slot-scope="scope">
  114. <el-button @click="compile(scope.row)" type="text" size="small"
  115. >编辑</el-button
  116. >
  117. <el-button
  118. v-if="scope.row.state == 0"
  119. @click="start(scope.row, 1)"
  120. type="text"
  121. size="small"
  122. >启用</el-button
  123. >
  124. <el-button
  125. v-else
  126. style="color: #666"
  127. @click="start(scope.row, 0)"
  128. type="text"
  129. size="small"
  130. >停用</el-button
  131. >
  132. <el-button
  133. style="color: #f00"
  134. @click="deleted(scope.row)"
  135. type="text"
  136. size="small"
  137. >删除</el-button
  138. >
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <div class="pagination-container">
  143. <el-pagination
  144. @current-change="handleCurrentChange"
  145. :current-page.sync="formInline.pageNum"
  146. layout="total, prev, pager, next"
  147. :page-size="formInline.pageSize"
  148. :total="formInline.totalSize"
  149. >
  150. </el-pagination>
  151. </div>
  152. </div>
  153. <!-- 弹出层 -->
  154. <!-- 导入 -->
  155. <el-dialog
  156. title="导入文件"
  157. :visible.sync="tolead"
  158. width="400px"
  159. @close="handleClose"
  160. >
  161. <el-alert title="请点击模板下载文件附件" type="success" :closable="false">
  162. </el-alert>
  163. <p class="model-center" @click="download">模板下载</p>
  164. <div class="UPcondition">
  165. <p>所属风场:</p>
  166. <el-select
  167. v-model="subordinate"
  168. placeholder="请选择"
  169. value-key="fieldCode"
  170. >
  171. <el-option
  172. v-for="item in subordinatedata"
  173. :key="item.fieldCode"
  174. :label="item.fieldName"
  175. :value="item.fieldCode"
  176. >
  177. </el-option>
  178. </el-select>
  179. </div>
  180. <el-upload
  181. class="upload-demo"
  182. :file-list="fileList"
  183. drag
  184. action
  185. :multiple="false"
  186. :before-upload="beforeUpload"
  187. :limit="1"
  188. :auto-upload="false"
  189. :on-change="handleOnChange"
  190. accept=".xlsx"
  191. >
  192. <i class="el-icon-upload"></i>
  193. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  194. <div class="el-upload__tip" slot="tip">
  195. 只能上传xlsx文件,且不超过5MB
  196. </div>
  197. </el-upload>
  198. <span slot="footer" class="dialog-footer">
  199. <el-button @click="handleClose" size="small">取 消</el-button>
  200. <el-button type="primary" @click="UPsubmit" size="small"
  201. >提交</el-button
  202. >
  203. </span>
  204. </el-dialog>
  205. <!-- 新增 -->
  206. <el-dialog
  207. :title="title"
  208. :visible.sync="nuedialog"
  209. width="1000px"
  210. @close="resetForm('ruleForm')"
  211. >
  212. <el-form
  213. :model="ruleForm"
  214. :rules="rules"
  215. ref="ruleForm"
  216. label-width="100px"
  217. class="demo-ruleForm"
  218. >
  219. <div class="form-row">
  220. <el-form-item label="风机名称:" prop="engineName">
  221. <el-input v-model="ruleForm.engineName" size="small"></el-input>
  222. </el-form-item>
  223. <el-form-item label="关联风场:" prop="fieldCode">
  224. <el-select
  225. v-model="ruleForm.fieldCode"
  226. filterable
  227. placeholder="请选择"
  228. size="small"
  229. >
  230. <el-option
  231. v-for="item in fieldCodeOptions"
  232. :key="item.fieldCode"
  233. :label="item.fieldName"
  234. :value="item.fieldCode"
  235. >
  236. </el-option>
  237. </el-select>
  238. </el-form-item>
  239. </div>
  240. <div class="form-row">
  241. <el-form-item label="机型编号:" prop="millTypeCode">
  242. <el-select
  243. v-model="ruleForm.millTypeCode"
  244. placeholder="请选择"
  245. size="small"
  246. >
  247. <el-option
  248. v-for="item in millTypeCodeOptions"
  249. :key="item.millTypeCode"
  250. :label="item.machineTypeCode"
  251. :value="item.millTypeCode"
  252. >
  253. </el-option>
  254. </el-select>
  255. </el-form-item>
  256. <el-form-item label="额定容量:" prop="ratedCapacity">
  257. <el-input v-model="ruleForm.ratedCapacity" size="small"></el-input>
  258. </el-form-item>
  259. </div>
  260. <div class="form-row">
  261. <el-form-item label="海拔高度:" prop="elevationHeight">
  262. <el-input
  263. v-model="ruleForm.elevationHeight"
  264. size="small"
  265. ></el-input>
  266. </el-form-item>
  267. <el-form-item label="经度:" prop="longitude">
  268. <el-input v-model="ruleForm.longitude" size="small"></el-input>
  269. </el-form-item>
  270. </div>
  271. <div class="form-row">
  272. <el-form-item label="纬度:" prop="latitude">
  273. <el-input v-model="ruleForm.latitude" size="small"></el-input>
  274. </el-form-item>
  275. <el-form-item label="轮廓高度:" prop="hubHeight">
  276. <el-input v-model="ruleForm.hubHeight" size="small"></el-input>
  277. </el-form-item>
  278. </div>
  279. <div class="form-row">
  280. <el-form-item label="是否标杆:" prop="sightcing">
  281. <el-select
  282. v-model="ruleForm.sightcing"
  283. placeholder="请选择"
  284. size="small"
  285. >
  286. <el-option
  287. v-for="item in sightcingOptions"
  288. :key="item.value"
  289. :label="item.label"
  290. :value="item.value"
  291. >
  292. </el-option>
  293. </el-select>
  294. </el-form-item>
  295. <el-form-item label="额定风速:" prop="rated_wind_speed">
  296. <el-input
  297. v-model="ruleForm.rated_wind_speed"
  298. size="small"
  299. ></el-input>
  300. </el-form-item>
  301. </div>
  302. <div class="form-row">
  303. <el-form-item label="切入风速:" prop="ratedCutInWindspeed">
  304. <el-input
  305. v-model="ruleForm.ratedCutInWindspeed"
  306. size="small"
  307. ></el-input>
  308. </el-form-item>
  309. <el-form-item label="切出风速:" prop="ratedCutOutWindspeed">
  310. <el-input
  311. v-model="ruleForm.ratedCutOutWindspeed"
  312. size="small"
  313. ></el-input>
  314. </el-form-item>
  315. </div>
  316. </el-form>
  317. <div class="form-buttons">
  318. <el-button type="primary" @click="submitForm('ruleForm')"
  319. >确定</el-button
  320. >
  321. <el-button @click="resetForm('ruleForm')">取消</el-button>
  322. </div>
  323. </el-dialog>
  324. <!-- 风机详情 -->
  325. <el-dialog title="风机详情" :visible.sync="unusualdialog" width="800px">
  326. <div class="general">
  327. <div class="condition">
  328. <p>关联风场:</p>
  329. <span>{{ particularsdata.fieldCode }}</span>
  330. </div>
  331. <div class="condition">
  332. <p>风机名称:</p>
  333. <span>{{ particularsdata.engineCode }}</span>
  334. </div>
  335. <div class="condition">
  336. <p>风机名称:</p>
  337. <span>{{ particularsdata.engineName }}</span>
  338. </div>
  339. <div class="condition">
  340. <p>机型编号:</p>
  341. <span>{{ particularsdata.millTypeCode }}</span>
  342. </div>
  343. <div class="condition">
  344. <p>额定容量:</p>
  345. <span>{{ particularsdata.ratedCapacity }}</span> <span>(kW)</span>
  346. </div>
  347. <div class="condition">
  348. <p>海拔高度:</p>
  349. <span>{{ particularsdata.elevationHeight }}</span> <span>(米)</span>
  350. </div>
  351. <div class="condition">
  352. <p>经度:</p>
  353. <span>{{ particularsdata.longitude }}</span>
  354. </div>
  355. <div class="condition">
  356. <p>纬度:</p>
  357. <span>{{ particularsdata.latitude }}</span>
  358. </div>
  359. <div class="condition">
  360. <p>额定风速:</p>
  361. <span>{{ particularsdata.rated_wind_speed }}</span
  362. ><span>(m/s)</span>
  363. </div>
  364. <div class="condition">
  365. <p>切入风速:</p>
  366. <span>{{ particularsdata.ratedCutInWindspeed }}</span
  367. ><span>(m/s)</span>
  368. </div>
  369. <div class="condition">
  370. <p>切出风速:</p>
  371. <span>{{ particularsdata.ratedCutOutWindspeed }}</span
  372. ><span>(m/s)</span>
  373. </div>
  374. <div class="condition">
  375. <p>轮廓高度:</p>
  376. <span>{{ particularsdata.hubHeight }}</span> <span>(米)</span>
  377. </div>
  378. <div class="condition">
  379. <p>是否标杆:</p>
  380. <span>{{ particularsdata.sightcing == 1 ? "是" : "否" }}</span>
  381. </div>
  382. <div class="condition">
  383. <p>状态:</p>
  384. <span>{{ particularsdata.state == 1 ? "启用" : "停用" }}</span>
  385. </div>
  386. </div>
  387. </el-dialog>
  388. </div>
  389. </template>
  390. <script>
  391. import {
  392. createWindEngineGroup,
  393. delWindEngineGroup,
  394. getWindEngineGroup,
  395. getWindEngineMillList,
  396. getWindFieldNames,
  397. updateStateWindEngineGroup,
  398. updateWindEngineGroup,
  399. windEngineGrouPage,
  400. getAllTemplate,
  401. windEngineGroupImportData,
  402. } from "@/api/ledger.js";
  403. export default {
  404. data() {
  405. return {
  406. loading: false,
  407. formInline: {
  408. fieldCode: "",
  409. timeQuantum: [],
  410. pageNum: 1,
  411. pageSize: 10,
  412. totalSize: 0,
  413. },
  414. startDate: "",
  415. endDate: "",
  416. tableData: [],
  417. particularsdata: [],
  418. ruleForm: {
  419. fieldCode: "",
  420. engineName: "",
  421. airdensity: "",
  422. millTypeCode: "",
  423. ratedCapacity: "",
  424. elevationHeight: "",
  425. longitude: "",
  426. latitude: "",
  427. hubHeight: "",
  428. sightcing: "",
  429. rated_wind_speed: "",
  430. ratedCutInWindspeed: "",
  431. ratedCutOutWindspeed: "",
  432. },
  433. fieldCodeOptions: [],
  434. millTypeCodeOptions: [],
  435. sightcingOptions: [
  436. {
  437. value: 1,
  438. label: "是",
  439. },
  440. {
  441. value: 2,
  442. label: "否",
  443. },
  444. ],
  445. rules: {
  446. fieldCode: [
  447. { required: true, message: "请选择关联风场", trigger: "change" },
  448. ],
  449. engineName: [
  450. { required: true, message: "请输入风机名称", trigger: "blur" },
  451. ],
  452. millTypeCode: [
  453. { required: true, message: "请输入机型编号", trigger: "blur" },
  454. ],
  455. ratedCapacity: [
  456. { required: true, message: "请输入额定容量", trigger: "blur" },
  457. ],
  458. longitude: [
  459. { required: true, message: "请输入经度", trigger: "blur" },
  460. { validator: this.validateNumber, trigger: "blur" },
  461. ],
  462. latitude: [
  463. { required: true, message: "请输入纬度", trigger: "blur" },
  464. { validator: this.validateNumber, trigger: "blur" },
  465. ],
  466. hubHeight: [
  467. { required: true, message: "请输入轮廓高度", trigger: "blur" },
  468. { validator: this.validateNumbertwo, trigger: "blur" },
  469. ],
  470. elevationHeight: [
  471. { required: true, message: "请输入海拔高度", trigger: "blur" },
  472. { validator: this.validateNumbertwo, trigger: "blur" },
  473. ],
  474. sightcing: [
  475. { required: true, message: "请选择是否标杆", trigger: "change" },
  476. ],
  477. },
  478. subordinatedata: [],
  479. subordinate: "",
  480. AllTemplateurl: "",
  481. // 新增信息
  482. engineName: "",
  483. airdensity: "",
  484. fieldCode: "",
  485. millTypeCode: "",
  486. sheng: "",
  487. shengOptions: [],
  488. shi: "",
  489. shiOptions: [],
  490. elevationHeight: "",
  491. latitude: "",
  492. sightcing: "",
  493. fileList: [],
  494. globalFileList: [],
  495. nuedialog: false,
  496. unusualdialog: false,
  497. tolead: false,
  498. isEdit: false,
  499. title: "",
  500. };
  501. },
  502. created() {
  503. this.onSubmit();
  504. this.windsite();
  505. this.relevancy();
  506. this.getAllTemplate();
  507. },
  508. methods: {
  509. rowStyle() {
  510. return "text-align:center";
  511. },
  512. onDateChange(date) {
  513. if (Array.isArray(date)) {
  514. this.startDate = this.$formatDate(date[0]);
  515. this.endDate = this.$formatDate(date[1]);
  516. if (this.endDate < this.startDate) {
  517. this.endDate = this.startDate;
  518. }
  519. } else {
  520. this.startDate = null;
  521. this.endDate = null;
  522. }
  523. },
  524. //获取模板
  525. getAllTemplate() {
  526. getAllTemplate().then((res) => {
  527. this.AllTemplateurl = res.data.draught;
  528. });
  529. },
  530. // 下载模板
  531. download() {
  532. if (this.AllTemplateurl) {
  533. const link = document.createElement("a");
  534. link.href = this.AllTemplateurl;
  535. link.download = ""; // 可以设置默认下载文件名
  536. link.target = "_blank"; // 新窗口打开
  537. document.body.appendChild(link);
  538. link.click();
  539. document.body.removeChild(link);
  540. } else {
  541. console.error("URL is not set");
  542. }
  543. },
  544. // 数字验证
  545. validateNumber(rule, value, callback) {
  546. const numberRegex = /^\d{1,3}(\.\d{1,8})?$/; // 匹配不超过四位数且小数点后不超过二位数的数字
  547. if (!value) {
  548. callback(new Error("该项不能为空"));
  549. } else if (!numberRegex.test(value)) {
  550. callback(
  551. new Error("该项必须为不超过三位数且小数点后不超过八位数的数字")
  552. );
  553. } else {
  554. callback();
  555. }
  556. },
  557. validateNumbertwo(rule, value, callback) {
  558. const numberRegex = /^\d{1,4}(\.\d{1,2})?$/; // 匹配不超过四位数且小数点后不超过二位数的数字
  559. if (!value) {
  560. callback(new Error("该项不能为空"));
  561. } else if (!numberRegex.test(value)) {
  562. callback(
  563. new Error("该项必须为不超过四位数且小数点后不超过两位数的数字")
  564. );
  565. } else {
  566. callback();
  567. }
  568. },
  569. // 查询
  570. onSubmit() {
  571. let paramsData = {
  572. engineName: this.formInline.engineName || undefined,
  573. beginTime: this.startDate || undefined,
  574. endTime: this.endDate || undefined,
  575. pageNum: this.formInline.pageNum || 1,
  576. pageSize: 10,
  577. };
  578. this.loading = true;
  579. windEngineGrouPage(paramsData)
  580. .then((res) => {
  581. this.tableData = res.data.list;
  582. this.formInline.totalSize = res.data.totalSize;
  583. this.loading = false;
  584. })
  585. .catch((error) => {
  586. console.error(error);
  587. });
  588. },
  589. // 停用
  590. start(row, type) {
  591. let objectval = {
  592. engineCode: row.engineCode,
  593. state: type === 0 ? 0 : 1,
  594. };
  595. updateStateWindEngineGroup(objectval).then((res) => {
  596. this.$message({
  597. message: "状态已更新成功",
  598. type: "success",
  599. });
  600. // this.$message(`${type === 1 ? '状态已更新成功' : '状态已更新成功'}`);
  601. row.state = type === 1 ? 0 : 1;
  602. this.onSubmit();
  603. });
  604. },
  605. //详情
  606. particulars(row) {
  607. this.unusualdialog = true;
  608. getWindEngineGroup({ engineCode: row.engineCode }).then((res) => {
  609. this.particularsdata = res.data;
  610. });
  611. },
  612. // 确认
  613. submitForm(formName) {
  614. this.$refs[formName].validate((valid) => {
  615. const objData = {
  616. fieldCode: this.ruleForm.fieldCode,
  617. engineName: this.ruleForm.engineName,
  618. millTypeCode: this.ruleForm.millTypeCode,
  619. ratedCapacity: this.ruleForm.ratedCapacity,
  620. elevationHeight: this.ruleForm.elevationHeight,
  621. longitude: this.ruleForm.longitude,
  622. latitude: this.ruleForm.latitude,
  623. hubHeight: this.ruleForm.hubHeight,
  624. sightcing: this.ruleForm.sightcing,
  625. rated_wind_speed: this.ruleForm.rated_wind_speed,
  626. ratedCutInWindspeed: this.ruleForm.ratedCutInWindspeed,
  627. ratedCutOutWindspeed: this.ruleForm.ratedCutOutWindspeed,
  628. };
  629. if (valid) {
  630. const API = this.isEdit
  631. ? updateWindEngineGroup(objData)
  632. : createWindEngineGroup(objData);
  633. API.then((res) => {
  634. if (res.code === -1) {
  635. this.$message({
  636. message: "操作成功 操作失败",
  637. type: " error",
  638. });
  639. } else {
  640. this.$message({
  641. message: "操作成功",
  642. type: "success",
  643. });
  644. }
  645. this.nuedialog = false;
  646. this.onSubmit();
  647. }).catch((error) => {});
  648. } else {
  649. console.log("表单验证失败");
  650. return false;
  651. }
  652. });
  653. },
  654. // 取消
  655. resetForm(formName) {
  656. this.$refs[formName].resetFields();
  657. this.nuedialog = false;
  658. },
  659. // 获取风场
  660. windsite() {
  661. debugger;
  662. getWindFieldNames().then((res) => {
  663. this.fieldCodeOptions = res.data;
  664. this.subordinatedata = res.data;
  665. });
  666. },
  667. // 获取机型
  668. async relevancy() {
  669. try {
  670. const res = await getWindEngineMillList();
  671. this.millTypeCodeOptions = res.data;
  672. } catch (error) {
  673. console.error("Error fetching wind engine mill list:", error);
  674. }
  675. },
  676. //分页数据切换
  677. handleCurrentChange(val) {
  678. this.formInline.pageNum = val;
  679. this.onSubmit();
  680. },
  681. // 重置
  682. reset() {
  683. this.formInline.engineName = "";
  684. this.formInline.timeQuantum = "";
  685. this.onSubmit();
  686. },
  687. //导入提交
  688. UPsubmit() {
  689. let filedata = {
  690. fieldCode: this.subordinate,
  691. file: this.globalFileList,
  692. };
  693. if (filedata.file == "") {
  694. this.$message({
  695. message: "请先提交附件",
  696. type: "warning",
  697. });
  698. } else {
  699. windEngineGroupImportData(filedata)
  700. .then((res) => {
  701. console.log(res);
  702. this.uploadingPOP = false;
  703. if (res.code === -1) {
  704. this.$message({
  705. message: "上传失败",
  706. type: "error",
  707. });
  708. } else {
  709. this.tolead = false;
  710. this.$message({
  711. message: "上传成功",
  712. type: "success",
  713. });
  714. this.onSubmit();
  715. this.handleClose();
  716. }
  717. })
  718. .catch((error) => {});
  719. }
  720. console.log(filedata);
  721. // this.tolead = false
  722. },
  723. // 新增
  724. newly() {
  725. this.nuedialog = false;
  726. },
  727. // 编辑
  728. compile(row) {
  729. getWindEngineGroup({ engineCode: row.engineCode }).then((res) => {
  730. const item = JSON.parse(JSON.stringify(res.data));
  731. this.detail = item;
  732. Object.keys(this.ruleForm).forEach((key) => {
  733. this.ruleForm[key] = item[key];
  734. });
  735. });
  736. this.nuedialog = true;
  737. this.title = "编辑";
  738. this.isEdit = true;
  739. },
  740. // 删除
  741. deleted(row) {
  742. console.log(row, "row");
  743. if (row.state == "1") {
  744. this.$message({
  745. type: "error",
  746. message: "该项处于启用状态,无法删除!",
  747. });
  748. return;
  749. }
  750. this.$confirm("此操作将永久删除该文件,是否继续?", "提示", {
  751. confirmButtonText: "确定",
  752. cancelButtonText: "取消",
  753. type: "warning",
  754. })
  755. .then(() => {
  756. delWindEngineGroup({ engineCode: row.engineCode }).then((res) => {
  757. this.onSubmit();
  758. // 执行删除操作
  759. this.$message({
  760. type: "success",
  761. message: "删除成功!",
  762. });
  763. });
  764. })
  765. .catch(() => {
  766. // 取消删除
  767. this.$message({
  768. type: "info",
  769. message: "已取消删除",
  770. });
  771. });
  772. },
  773. // 导入
  774. upfile() {
  775. this.tolead = true;
  776. },
  777. // 新增
  778. newnuedialog() {
  779. this.nuedialog = true;
  780. this.title = "新增";
  781. },
  782. // 附件验证
  783. beforeUpload(fileList) {
  784. const isXLSX =
  785. fileList.type ===
  786. "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  787. if (!isXLSX) {
  788. this.$message.error("只能上传xlsx文件");
  789. }
  790. const isLt5MB = fileList.size / 1024 / 1024 < 5;
  791. if (!isLt5MB) {
  792. this.$message.error("文件大小不能超过5MB");
  793. }
  794. console.log(fileList, "fileList");
  795. return isXLSX && isLt5MB;
  796. },
  797. handleOnChange(fileList) {
  798. console.log(fileList);
  799. this.globalFileList = fileList.raw;
  800. },
  801. handleClose() {
  802. this.subordinate = "";
  803. this.fileList = [];
  804. this.tolead = false;
  805. },
  806. },
  807. };
  808. </script>
  809. <style lang="scss" scoped>
  810. .general {
  811. display: flex;
  812. flex-wrap: wrap;
  813. .condition {
  814. width: 50%;
  815. display: flex;
  816. p {
  817. width: 100px;
  818. text-align: right;
  819. line-height: 40px;
  820. margin-right: 10px;
  821. }
  822. span {
  823. line-height: 40px;
  824. }
  825. .el-select {
  826. width: 260px;
  827. }
  828. .el-input {
  829. width: 260px;
  830. }
  831. }
  832. }
  833. .UPcondition {
  834. display: flex;
  835. margin-bottom: 10px;
  836. p {
  837. width: 74px;
  838. text-align: right;
  839. line-height: 40px;
  840. }
  841. .el-select {
  842. width: 260px;
  843. }
  844. .el-input {
  845. width: 260px;
  846. }
  847. }
  848. .attachment {
  849. display: flex;
  850. padding-top: 10px;
  851. p {
  852. margin-right: 20px;
  853. color: #409eff;
  854. }
  855. }
  856. .model-center {
  857. color: #666;
  858. line-height: 40px;
  859. height: 40px;
  860. font-size: 14px;
  861. }
  862. .demo-ruleForm {
  863. .el-select {
  864. width: 260px;
  865. }
  866. .el-input {
  867. width: 260px;
  868. }
  869. .el-form-item {
  870. margin-bottom: 20px;
  871. }
  872. .form-row {
  873. display: flex;
  874. justify-content: space-between;
  875. }
  876. .el-form-item {
  877. width: 48%;
  878. }
  879. }
  880. .form-buttons {
  881. display: flex;
  882. justify-content: center;
  883. width: 100%;
  884. margin-top: 20px;
  885. /* optional: adds some space above the buttons */
  886. }
  887. .model-center {
  888. color: #409eff;
  889. cursor: pointer;
  890. line-height: 40px;
  891. height: 40px;
  892. font-size: 14px;
  893. }
  894. </style>