index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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="enterpriseName">
  5. <el-input
  6. v-model="queryParams.enterpriseName"
  7. placeholder="请输入企业名称"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="燃气成分" prop="component">
  14. <el-input
  15. v-model="queryParams.component"
  16. placeholder="请输入燃气成分"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="运输车辆车牌号" prop="carNumber" label-width="110px">
  23. <el-input
  24. v-model="queryParams.carNumber"
  25. placeholder="请输入运输车辆车牌号"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['housingconstruction:gassource:add']"
  45. >新增
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['housingconstruction:gassource:edit']"
  57. >修改
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['housingconstruction:gassource:remove']"
  69. >删除
  70. </el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="warning"
  75. plain
  76. icon="el-icon-download"
  77. size="mini"
  78. @click="handleExport"
  79. v-hasPermi="['housingconstruction:gassource:export']"
  80. >导出
  81. </el-button>
  82. </el-col>
  83. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  84. </el-row>
  85. <el-table v-loading="loading" :data="gassourceList" @selection-change="handleSelectionChange">
  86. <el-table-column type="selection" width="55" align="center"/>
  87. <el-table-column label="企业名称" align="center" prop="enterpriseName"/>
  88. <el-table-column label="来源地" align="center" prop="address"/>
  89. <el-table-column label="燃气成分" align="center" prop="component">
  90. <template slot-scope="scope">
  91. <dict-tag :options="dict.type.housingconstruction_component" :value="scope.row.component"/>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="入站时间" align="center" prop="joinInstationTime" width="180">
  95. <template slot-scope="scope">
  96. <span>{{ parseTime(scope.row.joinInstationTime, '{y}-{m}-{d}') }}</span>
  97. </template>
  98. </el-table-column>
  99. <el-table-column label="运输体积" align="center" prop="weight"/>
  100. <el-table-column label="运输车辆车牌号" align="center" prop="carNumber" />
  101. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  102. <template slot-scope="scope">
  103. <el-button
  104. size="mini"
  105. type="text"
  106. icon="el-icon-edit"
  107. @click="handleUpdate(scope.row)"
  108. v-hasPermi="['housingconstruction:gassource:edit']"
  109. >修改
  110. </el-button>
  111. <el-button
  112. size="mini"
  113. type="text"
  114. icon="el-icon-delete"
  115. @click="handleDelete(scope.row)"
  116. v-hasPermi="['housingconstruction:gassource:remove']"
  117. >删除
  118. </el-button>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <pagination
  123. v-show="total>0"
  124. :total="total"
  125. :page.sync="queryParams.pageNum"
  126. :limit.sync="queryParams.pageSize"
  127. @pagination="getList"
  128. />
  129. <!-- 添加或修改气源数据对话框 -->
  130. <el-dialog :title="title" :visible.sync="open" width="1300px" append-to-body class="form-style">
  131. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  132. <el-row :gutter="24">
  133. <el-col :span="12">
  134. <el-form-item label="所属企业" prop="enterpriseId">
  135. <el-select v-model="form.enterpriseId" placeholder="请选择所属企业" @change="handleEnterpriseChange">
  136. <el-option
  137. v-for="data in enterpriseList"
  138. :key="data.id"
  139. :label="data.enterpriseName"
  140. :value="data.id"
  141. ></el-option>
  142. </el-select>
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="12">
  146. <el-form-item label="来源地" prop="address">
  147. <el-input v-model="form.address" placeholder="请输入来源地"/>
  148. </el-form-item>
  149. </el-col>
  150. </el-row>
  151. <el-row :gutter="24">
  152. <el-col :span="12">
  153. <el-form-item label="燃气成分" prop="component">
  154. <el-select v-model="form.component" placeholder="请选择燃气成分">
  155. <el-option
  156. v-for="dict in dict.type.housingconstruction_component"
  157. :key="dict.value"
  158. :label="dict.label"
  159. :value="dict.value"
  160. ></el-option>
  161. </el-select>
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="12">
  165. <el-form-item label="入站时间" prop="joinInstationTime">
  166. <el-date-picker clearable size="small"
  167. v-model="form.joinInstationTime"
  168. type="date"
  169. value-format="yyyy-MM-dd"
  170. placeholder="选择入站时间">
  171. </el-date-picker>
  172. </el-form-item>
  173. </el-col>
  174. </el-row>
  175. <el-row :gutter="24">
  176. <el-col :span="12">
  177. <el-form-item label="运输车辆" prop="carId">
  178. <el-select v-model="form.carId" filterable placeholder="请选择运输车辆" @change="handleCarChange">
  179. <el-option
  180. v-for="data in carList"
  181. :key="data.id"
  182. :label="data.carNumber"
  183. :value="data.id"
  184. ></el-option>
  185. </el-select>
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="12">
  189. <el-form-item label="运输体积" prop="weight">
  190. <el-input v-model="form.weight" placeholder="请输入运输体积"/>
  191. </el-form-item>
  192. </el-col>
  193. </el-row>
  194. <el-row :gutter="24">
  195. <el-col :span="12">
  196. <el-form-item label="所属部门" prop="deptId">
  197. <treeselect v-model="form.deptId" :options="deptOptions" multiple:false :show-count="true"
  198. placeholder="请选择部门" @select="hx" :noResultsText="'空'" :noOptionsText="'空'"/>
  199. </el-form-item>
  200. </el-col>
  201. </el-row>
  202. <el-row :gutter="24">
  203. <el-form-item label="危化品检测报告" prop="fileUrl" label-width="130px">
  204. <fileUpload v-model="form.fileUrl" :setFileName="setFileName" :removeFileName="removeFileName"></fileUpload>
  205. </el-form-item>
  206. </el-row>
  207. <el-row :gutter="24">
  208. <el-form-item label="危化品运输车辆许可" prop="attachPaths" label-width="160px">
  209. <ImageUpload v-model="form.attachPaths" ref="ImageUpload" :fileType="['png', 'jpg', 'jpeg']" :value="form.attachPaths" @input="getUrl" :limit="10"></ImageUpload>
  210. </el-form-item>
  211. </el-row>
  212. </el-form>
  213. <div slot="footer" class="dialog-footer">
  214. <el-button type="primary" @click="submitForm">确 定</el-button>
  215. <el-button @click="cancel">取 消</el-button>
  216. </div>
  217. </el-dialog>
  218. </div>
  219. </template>
  220. <script>
  221. import {
  222. addGassource,
  223. delGassource,
  224. getGassource,
  225. listGassource,
  226. updateGassource
  227. } from "@/api/data/housingconstruction/gassource";
  228. import {getListAll} from "@/api/data/housingconstruction/enterprise";
  229. import deptselector from "@/views/components/deptselector.vue";
  230. import Treeselect from "@riophae/vue-treeselect";
  231. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  232. import {treeselect} from "@/api/system/dept";
  233. import {getCarList} from "@/api/data/housingconstruction/car";
  234. import DataImageUpload from "@/components/ImageUpload/dataUpload.vue";
  235. import FileUpload from '@/views/components/FileUpload/index.vue'
  236. export default {
  237. name: "Gassource",
  238. components: {DataImageUpload, deptselector, Treeselect, FileUpload},
  239. dicts: ['housingconstruction_component'],
  240. data() {
  241. return {
  242. // 遮罩层
  243. loading: true,
  244. // 选中数组
  245. ids: [],
  246. // 非单个禁用
  247. single: true,
  248. // 非多个禁用
  249. multiple: true,
  250. // 显示搜索条件
  251. showSearch: true,
  252. fileNames: [],
  253. // 总条数
  254. total: 0,
  255. // 气源数据表格数据
  256. gassourceList: [],
  257. //企业信息列表
  258. enterpriseList: [],
  259. // 部门树选项
  260. deptOptions: [],
  261. //车辆列表
  262. carList: [],
  263. // 弹出层标题
  264. title: "",
  265. // 是否显示弹出层
  266. open: false,
  267. // 查询参数
  268. queryParams: {
  269. pageNum: 1,
  270. pageSize: 10,
  271. enterpriseName: null,
  272. address: null,
  273. component: null,
  274. joinInstationTime: null,
  275. weight: null,
  276. carNumber: null
  277. },
  278. // 表单参数
  279. form: {
  280. fileUrl: '',
  281. fileName: '',
  282. fileUrlList: [],
  283. fileNameList: []
  284. },
  285. // 表单校验
  286. rules: {
  287. enterpriseId: [
  288. {required: true, message: "企业不能为空", trigger: "blur"}
  289. ],
  290. address: [
  291. {required: true, message: "来源地不能为空", trigger: "blur"}
  292. ],
  293. component: [
  294. {required: true, message: "燃气成分不能为空", trigger: "blur"}
  295. ],
  296. joinInstationTime: [
  297. {required: true, message: "入站时间不能为空", trigger: "blur"}
  298. ],
  299. weight: [
  300. {required: true, message: "运输体积不能为空", trigger: "blur"}
  301. ],
  302. carId: [
  303. {required: true, message: "运输车辆不能为空", trigger: "blur"}
  304. ],
  305. deptId: [
  306. {required: true, message: "所属部门不能为空", trigger: "blur"}
  307. ],
  308. fileUrl: [
  309. {required: true, message: "危化品检测报告不能为空", trigger: "blur"}
  310. ],
  311. attachPaths: [
  312. {required: true, message: "危化品运输车车辆许可不能为空", trigger: "blur"}
  313. ],
  314. }
  315. };
  316. },
  317. created() {
  318. this.getList();
  319. this.getTreeselect();
  320. this.getEnterpriseList();
  321. this.getCarList();
  322. },
  323. methods: {
  324. /** 附件:图片 **/
  325. getUrl(url) {
  326. //获取图片全路径 例:http://{{ ip }}:{{ port }}/group1/M00/00/07/wKgKEGVxMCiAZbvVAAJE9SGvagw915.jpg
  327. this.form.attachPaths = url
  328. //获取图片路径 例:group1/M00/00/07/wKgKEGVxL6eACFv2AAJE9SGvagw622.jpg
  329. // this.form.attachPaths = this.$refs.ImageUpload.dialogName
  330. },
  331. /** 附件:文件 **/
  332. setFileName(fileName) {
  333. let that = this
  334. that.fileNames.push(fileName)
  335. },
  336. removeFileName(index) {
  337. let that = this
  338. that.fileNames.splice(index, 1);
  339. let fileurls = that.form.fileUrl.split(",")
  340. fileurls.splice(index, 1)
  341. that.form.fileUrl = fileurls.toString()
  342. },
  343. /** 获取车辆列表 **/
  344. getCarList(){
  345. getCarList().then(res=>{
  346. this.carList = res.data;
  347. })
  348. },
  349. /** 查询部门下拉树结构 */
  350. getTreeselect() {
  351. treeselect().then(response => {
  352. this.deptOptions = response.data;
  353. });
  354. },
  355. hx(node) {
  356. this.form.dataDeptId = node.id
  357. this.form.deptId = node.id
  358. this.form.deptName = node.label
  359. this.$refs.form.validateField("deptId")
  360. },
  361. handleEnterpriseChange(newId) {
  362. const selectedEnterprise = this.enterpriseList.find(item => item.id === newId);
  363. if (selectedEnterprise) {
  364. this.form.enterpriseName = selectedEnterprise.enterpriseName;
  365. } else {
  366. this.form.enterpriseName = '';
  367. }
  368. },
  369. handleCarChange(newId){
  370. const selectedCar = this.carList.find(item => item.id === newId);
  371. if (selectedCar) {
  372. this.form.carNumber = selectedCar.carNumber;
  373. } else {
  374. this.form.carNumber = '';
  375. }
  376. },
  377. getEnterpriseList(){
  378. getListAll().then(res=>{
  379. this.enterpriseList = res.data
  380. })
  381. },
  382. /** 查询气源数据列表 */
  383. getList() {
  384. this.loading = true;
  385. listGassource(this.queryParams).then(response => {
  386. this.gassourceList = response.rows;
  387. this.total = response.total;
  388. this.loading = false;
  389. });
  390. },
  391. // 取消按钮
  392. cancel() {
  393. this.open = false;
  394. this.reset();
  395. },
  396. // 表单重置
  397. reset() {
  398. this.form = {
  399. id: null,
  400. createBy: null,
  401. createName: null,
  402. createTime: null,
  403. updateBy: null,
  404. updateName: null,
  405. updateTime: null,
  406. deptId: null,
  407. deptName: null,
  408. enterpriseId: null,
  409. enterpriseName: null,
  410. address: null,
  411. component: null,
  412. joinInstationTime: null,
  413. weight: null,
  414. carNumber: null
  415. };
  416. this.fileNames = [];
  417. this.resetForm("form");
  418. },
  419. /** 搜索按钮操作 */
  420. handleQuery() {
  421. this.queryParams.pageNum = 1;
  422. this.getList();
  423. },
  424. /** 重置按钮操作 */
  425. resetQuery() {
  426. this.resetForm("queryForm");
  427. this.handleQuery();
  428. },
  429. // 多选框选中数据
  430. handleSelectionChange(selection) {
  431. this.ids = selection.map(item => item.id)
  432. this.single = selection.length !== 1
  433. this.multiple = !selection.length
  434. },
  435. /** 新增按钮操作 */
  436. handleAdd() {
  437. this.reset();
  438. this.open = true;
  439. this.title = "添加气源数据";
  440. },
  441. /** 修改按钮操作 */
  442. handleUpdate(row) {
  443. this.reset();
  444. const id = row.id || this.ids
  445. getGassource(id).then(response => {
  446. const list = response.data.fileUrl.split(',');
  447. if (response.data.fileUrl != "") {
  448. for (var a = 0; a < list.length; a++) {
  449. let listurl = list[a].split('+')
  450. this.fileNames.push(listurl[1])
  451. }
  452. }
  453. this.form = response.data;
  454. this.open = true;
  455. this.title = "修改气源数据";
  456. });
  457. },
  458. /** 提交按钮 */
  459. submitForm() {
  460. this.$refs["form"].validate(valid => {
  461. if (valid) {
  462. this.form.fileName = this.fileNames.toString()
  463. if (this.form.id != null) {
  464. updateGassource(this.form).then(response => {
  465. this.$modal.msgSuccess("修改成功");
  466. this.fileNames = [];
  467. this.open = false;
  468. this.getList();
  469. });
  470. } else {
  471. addGassource(this.form).then(response => {
  472. this.$modal.msgSuccess("新增成功");
  473. this.open = false;
  474. this.fileNames = [];
  475. this.getList();
  476. });
  477. }
  478. }
  479. });
  480. },
  481. /** 删除按钮操作 */
  482. handleDelete(row) {
  483. const ids = row.id || this.ids;
  484. this.$modal.confirm('是否确认删除气源数据编号为"' + ids + '"的数据项?').then(function () {
  485. return delGassource(ids);
  486. }).then(() => {
  487. this.getList();
  488. this.$modal.msgSuccess("删除成功");
  489. }).catch(() => {
  490. });
  491. },
  492. /** 导出按钮操作 */
  493. handleExport() {
  494. this.download('sooka-sponest-center-data/gassource/export', {
  495. ...this.queryParams
  496. }, `气源数据_${format_date(new Date())}.xlsx`)
  497. }
  498. }
  499. };
  500. </script>