index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div class="execution">
  3. <basic-container>
  4. <div style="margin-bottom: .5%">
  5. <span>场站:</span>
  6. <el-select v-model="stationCode" placeholder="请选择场站" clearable>
  7. <el-option
  8. v-for="item in stationList"
  9. :key="item.value"
  10. :label="item.label"
  11. :value="item.value">
  12. </el-option>
  13. </el-select>
  14. <el-button-group style="margin-left: 1%">
  15. <el-button type="primary" icon="el-icon-search" :loading="tableLoading" @click="getList()">查询</el-button>
  16. <el-button type="primary" icon="el-icon-circle-plus-outline" @click="handleAdd()" :loading="tableLoading">添加</el-button>
  17. </el-button-group>
  18. </div>
  19. <el-table
  20. :data="tableData"
  21. :header-cell-style="{background:'#ECF1FE'}"
  22. border
  23. style="width: 100%">
  24. <el-table-column prop="stationCode" label="场站名称" align="center"
  25. :formatter="formatStationCode"></el-table-column>
  26. <el-table-column align="center" prop="cid" label="通道名称" :formatter="formatCid"></el-table-column>
  27. <el-table-column align="center" prop="urlStatus" label="使用状态" :formatter="formatStatus"></el-table-column>
  28. <el-table-column align="center" prop="url" label="路径"></el-table-column>
  29. <el-table-column align="center" prop="forecastManufactor" label="预测厂家"
  30. :formatter="formatForecastManufactor"></el-table-column>
  31. <el-table-column align="center" label="操作" width="200">
  32. <template slot-scope="scope">
  33. <el-button
  34. size="mini"
  35. type="warning"
  36. :loading="tableLoading"
  37. @click="handleEdit(scope.$index, scope.row)">编辑
  38. </el-button>
  39. <el-button
  40. size="mini"
  41. type="danger"
  42. :loading="tableLoading"
  43. @click="handleDelete(scope.$index, scope.row)">删除
  44. </el-button>
  45. </template>
  46. </el-table-column>
  47. </el-table>
  48. <el-pagination
  49. @size-change="handleSizeChange"
  50. @current-change="handleCurrentChange"
  51. :current-page="this.page.currentPage"
  52. :page-sizes="[10, 20, 50, 100]"
  53. :page-size="this.page.pageSize"
  54. layout="->,total, sizes, prev, pager, next, jumper"
  55. :total="this.page.total">
  56. </el-pagination>
  57. <el-dialog
  58. :title="title"
  59. :visible.sync="dialogVisible"
  60. :append-to-body="true"
  61. :close-on-click-modal="false"
  62. width="30%"
  63. :before-close="handleClose">
  64. <el-form ref="elform" :model="form" :rules="rules" label-width="80px">
  65. <el-form-item prop="stationCode" label="场站编码">
  66. <el-select v-model="form.stationCode" placeholder="请选择" style="width: 100%">
  67. <el-option
  68. v-for="item in stationList"
  69. :key="item.value"
  70. :label="item.label"
  71. :value="item.value"
  72. >
  73. </el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item prop="cid" label="通道名字">
  77. <el-select v-model="form.cid" placeholder="请选择" style="width: 100%" :disabled="true">
  78. <el-option
  79. v-for="item in editChannelInfo"
  80. :key="item.id"
  81. :label="item.channelName"
  82. :value="item.id"
  83. >
  84. </el-option>
  85. </el-select>
  86. </el-form-item>
  87. <el-form-item prop="urlStatus" label="使用状态">
  88. <el-select v-model="form.urlStatus" placeholder="请选择" style="width: 100%">
  89. <el-option
  90. v-for="item in urlStatusOption"
  91. :key="item.value"
  92. :label="item.label"
  93. :value="item.value"
  94. >
  95. </el-option>
  96. </el-select>
  97. </el-form-item>
  98. <el-form-item prop="url" label="路径">
  99. <el-input v-model="form.url"></el-input>
  100. </el-form-item>
  101. <el-form-item prop="forecastManufactor" label="预测厂家">
  102. <el-select v-model="form.forecastManufactor" placeholder="请选择" style="width: 100%">
  103. <el-option
  104. v-for="item in forecastManufactorList"
  105. :key="item.value"
  106. :label="item.label"
  107. :value="item.value"
  108. >
  109. </el-option>
  110. </el-select>
  111. </el-form-item>
  112. </el-form>
  113. <div style="text-align: center">
  114. <el-button type="primary" @click="handleUpdate">保存</el-button>
  115. <el-button @click="handleCancel">取消</el-button>
  116. </div>
  117. </el-dialog>
  118. </basic-container>
  119. </div>
  120. </template>
  121. <script>
  122. import {fetchList, addObj, putObj, delObj} from '@/api/an/ParsingUrl'
  123. import {fetchListForSelects} from '@/api/an/forecastManufactor'
  124. import {mapGetters} from 'vuex'
  125. import mixin from '@/mixins/mixin.js'
  126. import {getStation} from "@/api/inverterinfo";
  127. export default {
  128. name: 'ParsingUrl',
  129. mixins: [mixin],
  130. props: {
  131. channelId: {
  132. type: String
  133. },
  134. channelInfo: {type: Object}
  135. },
  136. watch: {
  137. channelId() {
  138. this.getList()
  139. },
  140. channelInfo: {
  141. immediate: true,// 第一次立即监听
  142. handler(value) {
  143. this.editChannelInfo = []
  144. this.editChannelInfo.push(value)
  145. }
  146. }
  147. },
  148. data() {
  149. return {
  150. form: {},
  151. tunnel: {},
  152. searchForm: {},
  153. tableData: [],
  154. editChannelInfo: [],//父组件编辑的通道信息
  155. page: {
  156. total: 0, // 总页数
  157. currentPage: 1, // 当前页数
  158. pageSize: 20 // 每页显示多少条
  159. },
  160. tableLoading: false,
  161. stationCode:'',
  162. forecastManufactorList: [],// 预测厂家数据
  163. stationList: [],// 场站数据
  164. dialogVisible: false,
  165. dialogType: '',//新增还是编辑
  166. title:'',//弹框的文本
  167. urlStatusOption: [{value: '1', label: '使用'}, {value: '2', label: '停用'}],
  168. rules: {
  169. stationCode: {required: true, message: '请选择通道名称', trigger: 'blur'},
  170. urlStatus: {required: true, message: '请选择状态', trigger: 'blur'},
  171. url: {required: true, message: '请输入路径', trigger: 'blur'},
  172. forecastManufactor: {required: true, message: '请选择预测厂家', trigger: 'blur'},
  173. }
  174. }
  175. },
  176. computed: {
  177. ...mapGetters(['permissions']),
  178. permissionList() {
  179. return {
  180. addBtn: this.vaildData(this.permissions.da_tunnel_info_add, false),
  181. delBtn: this.vaildData(this.permissions.da_tunnel_info_del, false),
  182. editBtn: this.vaildData(this.permissions.da_tunnel_info_edit, false)
  183. };
  184. }
  185. },
  186. created() {
  187. this.getSelects()
  188. },
  189. methods: {
  190. getSelects() {
  191. // 预测厂家数据
  192. fetchListForSelects().then(response => {
  193. this.forecastManufactorList = response.data.data
  194. })
  195. // 场站数据
  196. getStation().then(response => {
  197. this.stationList = response.data.data
  198. })
  199. this.getList()
  200. },
  201. getList() {
  202. var page = this.page
  203. // if (this.searchForm.stationCode != '') {
  204. // this.form.stationCode = this.searchForm.stationCode
  205. // }
  206. // this.form.cId = this.channelId
  207. // this.searchForm = this.form
  208. // console.log(this.form)
  209. if(this.stationCode !== null && this.stationCode !== undefined && this.stationCode !== ''){
  210. this.searchForm ={stationCode:this.stationCode,cId:this.editChannelInfo[0].id,delFlag:0}
  211. }else {
  212. this.searchForm = {delFlag:0,cId:this.editChannelInfo[0].id}
  213. }
  214. this.tableLoading = true
  215. fetchList(Object.assign({
  216. current: page.currentPage,
  217. size: page.pageSize
  218. }, this.searchForm)).then(response => {
  219. this.tableData = response.data.data.records
  220. this.page.total = response.data.data.total
  221. this.tableLoading = false
  222. }).catch(() => {
  223. this.tableLoading = false
  224. })
  225. },
  226. handleSizeChange(val) {
  227. this.page.pageSize = val
  228. this.page.currentPage = 1
  229. this.getList();
  230. },
  231. handleCurrentChange(val) {
  232. this.page.currentPage = val
  233. this.getList();
  234. },
  235. handleAdd() {
  236. this.form = {}
  237. this.dialogType = "add"
  238. this.title = '新增&保存'
  239. this.form.cid = this.channelId
  240. this.dialogVisible = true
  241. },
  242. // 编辑按钮
  243. handleEdit(index, row) {
  244. this.form = row
  245. this.dialogType = "edit"
  246. this.title = '编辑&保存'
  247. this.dialogVisible = true
  248. },
  249. // 删除按钮
  250. handleDelete(index, row) {
  251. this.rowDel(row)
  252. },
  253. rowDel: function (row, index) {
  254. this.$confirm('是否确认删除ID为' + row.id, '提示', {
  255. confirmButtonText: '确定',
  256. cancelButtonText: '取消',
  257. type: 'warning'
  258. }).then(function () {
  259. return delObj(row.id)
  260. }).then(data => {
  261. this.$message.success('删除成功')
  262. this.getList(this.page)
  263. })
  264. },
  265. handleUpdate: function () {
  266. if (this.dialogType === 'add') {
  267. // row.cid = this.channelId
  268. // row.stationCode = this.stationCode
  269. addObj(this.form).then(data => {
  270. this.$message.success('添加成功')
  271. this.getList()
  272. this.dialogVisible = false
  273. }).catch((e) => {
  274. console.log('添加失败:' + e)
  275. });
  276. } else {
  277. putObj(this.form).then(data => {
  278. this.$message.success('修改成功')
  279. this.getList()
  280. this.dialogVisible = false
  281. }).catch(() => {
  282. console.log('修改失败:' + e)
  283. });
  284. }
  285. },
  286. // 弹框的关闭前的回调
  287. handleClose(done) {
  288. this.form = {}
  289. this.$nextTick(() => {
  290. this.$refs.elform.resetFields();
  291. })
  292. done()
  293. },
  294. handleCancel() {
  295. this.$nextTick(() => {
  296. this.$refs.elform.resetFields();
  297. })
  298. this.form = {}
  299. this.dialogVisible = false
  300. },
  301. formatStatus(row) {
  302. const urlStatus = this.urlStatusOption.find(w => w.value === row.urlStatus)
  303. return urlStatus !== undefined ? urlStatus.label : row.urlStatus
  304. },
  305. formatCid(row) {
  306. return this.editChannelInfo[0].id === row.cid ? this.editChannelInfo[0].channelName : row.cid
  307. },
  308. formatStationCode(row) {
  309. const station = this.stationList.find(w => w.value === row.stationCode)
  310. return station !== undefined ? station.label : row.stationCode
  311. },
  312. formatForecastManufactor(row) {
  313. const forecastManufactor = this.forecastManufactorList.find(w => w.value === row.forecastManufactor)
  314. return forecastManufactor !== undefined ? forecastManufactor.label : row.forecastManufactor
  315. }
  316. }
  317. }
  318. </script>