CameraBrand.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="cameraBrand">
  3. <!-- 查询 -->
  4. <query-conditions :formItems="searchList" @getQueryParams="handleQuery"></query-conditions>
  5. <!-- 表格 -->
  6. <new-table :height="600" :title="title" :listData="brandLists" :tableItems="tableItems" :shows="tableShows" @selectionChange="selectionChange">
  7. <template #right>
  8. <div>
  9. <el-button size="mini" type="primary" v-if="hasPerm('brand:add')" @click="dialogVisible = true">添加品牌</el-button>
  10. <el-button size="mini" type="danger" v-if="hasPerm('brand:del')" @click="delAll">批量删除</el-button>
  11. </div>
  12. </template>
  13. <template #streamType="scope">
  14. <div>
  15. <span v-if="scope.row.streamType === 0">主码流</span>
  16. <span v-else>辅码流</span>
  17. </div>
  18. </template>
  19. <template #handler="scope">
  20. <el-button size="mini" @click="edit(scope.row)" v-if="hasPerm('brand:edit')" style="margin-right: 10px">编辑</el-button>
  21. <el-popconfirm
  22. title=" 确定要删除这个区域吗?"
  23. @confirm="del(scope.row)"
  24. >
  25. <el-button type="danger" v-if="hasPerm('brand:del')" size="mini" slot="reference">删除</el-button>
  26. </el-popconfirm>
  27. </template>
  28. </new-table>
  29. <table-footer
  30. :totals="total"
  31. :size="pageSize"
  32. @sizeChange="sizeChange"
  33. @pageChange="pageChange"></table-footer>
  34. <!-- 新增编辑 -->
  35. <el-dialog
  36. :title="showType ? '编 辑' : '新 增'"
  37. :visible.sync="dialogVisible"
  38. width="30%">
  39. <div>
  40. <el-form ref="form" :model="form" :rules="rules" label-width="80px" size="mini">
  41. <el-form-item label="品牌名称" prop="brandName">
  42. <el-input v-model="form.brandName"></el-input>
  43. </el-form-item>
  44. <el-form-item label="主码流" prop="mainStream">
  45. <el-input v-model="form.mainStream"></el-input>
  46. </el-form-item>
  47. <el-form-item label="副码流" prop="assistStream">
  48. <el-input v-model="form.assistStream"></el-input>
  49. </el-form-item>
  50. <el-form-item label="所用码流" prop="streamType">
  51. <el-select v-model="form.streamType">
  52. <el-option v-for="item in options" :label="item.name" :value="item.id" :key="item.id"></el-option>
  53. </el-select>
  54. </el-form-item>
  55. <!-- <el-form-item label="主码流">-->
  56. <!-- <el-input v-model="form.mainStream"></el-input>-->
  57. <!-- </el-form-item>-->
  58. </el-form>
  59. </div>
  60. <span slot="footer" class="dialog-footer">
  61. <el-button @click="reset">取 消</el-button>
  62. <el-button type="primary" @click="onSubmit('form')">{{showType ? '更 新' : '新 增'}}</el-button>
  63. </span>
  64. </el-dialog>
  65. </div>
  66. </template>
  67. <script>
  68. import QueryConditions from "@/components/bioSafety/QueryConditions";
  69. import NewTable from "@/components/newTable/NewTable";
  70. import TableFooter from "@/components/TableFooter";
  71. import {brandList, addBarand, delBarand, editBarand } from '../../utils/api.js';
  72. import {arrToIds} from "@/utils";
  73. export default {
  74. name: "CameraBrand",
  75. components: {
  76. QueryConditions,
  77. NewTable,
  78. TableFooter
  79. },
  80. data() {
  81. return {
  82. searchList: [
  83. {
  84. type: 'input',
  85. label: '品牌搜索:',
  86. placeholder: '请输入品牌',
  87. field: 'keyWord'
  88. },
  89. ],
  90. brandLists: [],
  91. title: '摄像头品牌列表',
  92. tableItems: [
  93. {
  94. prop: 'brandName',
  95. label: '品牌名称',
  96. minWidth: '150',
  97. slotName: 'brandName'
  98. },
  99. {
  100. prop: 'mainStream',
  101. label: '主码流',
  102. minWidth: '150',
  103. slotName: 'mainStream'
  104. },
  105. {
  106. prop: 'assistStream',
  107. label: '副码流',
  108. minWidth: '150',
  109. slotName: 'assistStream'
  110. },
  111. {
  112. prop: 'streamType',
  113. label: '所用码流',
  114. minWidth: '150',
  115. slotName: 'streamType'
  116. },
  117. {
  118. label: '操作',
  119. minWidth: '150',
  120. slotName: 'handler'
  121. }
  122. ],
  123. tableShows: {
  124. showIndex: false,
  125. showSelect: true
  126. },
  127. pageNum: 1,
  128. pageSize: 20,
  129. total: 0,
  130. keyWord: '',
  131. form: {
  132. brandName: '',
  133. mainStream: '',
  134. assistStream: '',
  135. streamType: 0,
  136. },
  137. rules: {
  138. brandName: [
  139. { required: true, message: '品牌名称不能为空', trigger: 'blur' }
  140. ],
  141. mainStream: [
  142. { required: true, message: '主码流不能为空', trigger: 'blur' }
  143. ],
  144. assistStream: [
  145. { required: true, message: '副码流不能为空', trigger: 'blur' }
  146. ],
  147. streamType: [
  148. { required: true, message: '所用码流不能为空', trigger: 'change' }
  149. ]
  150. },
  151. options: [
  152. {
  153. id: 0,
  154. name: '主码流'
  155. },
  156. {
  157. id: 1,
  158. name: '辅码流'
  159. }
  160. ],
  161. dialogVisible: false,
  162. showType: false,
  163. selectList: []
  164. }
  165. },
  166. methods: {
  167. // 修改size
  168. sizeChange(val) {
  169. this.pageSize = val;
  170. this.init();
  171. },
  172. // 修改页数
  173. pageChange(val) {
  174. this.pageNum= val;
  175. this.init();
  176. },
  177. handleQuery(data) {
  178. this.keyWord = data.keyWord;
  179. this.pageNum = 1;
  180. this.init()
  181. },
  182. init() {
  183. let params = {
  184. current: this.pageNum,
  185. size: this.pageSize,
  186. brandName: this.keyWord
  187. }
  188. brandList(params).then(res => {
  189. if(res.code === 10000) {
  190. this.brandLists = res.data.records;
  191. this.total = res.data.total;
  192. }
  193. })
  194. },
  195. edit(row) {
  196. this.form = {
  197. id: row.id,
  198. brandName: row.brandName,
  199. mainStream: row.mainStream,
  200. assistStream: row.assistStream,
  201. streamType: row.streamType,
  202. }
  203. this.dialogVisible = true;
  204. this.showType = true;
  205. },
  206. // 批量选择
  207. selectionChange(rows) {
  208. this.selectList = rows;
  209. },
  210. // 批量删除
  211. delAll() {
  212. if(this.selectList.length > 0) {
  213. this.$confirm('此操作将永久删除这些品牌,是否继续?', '提示', {
  214. confirmButtonText: '确定',
  215. cancelButtonText: '取消',
  216. type: 'warning'
  217. }).then(() => {
  218. let ids = arrToIds(this.selectList);
  219. let params = {
  220. ids: ids
  221. }
  222. delBarand(params).then(res => {
  223. if(res.code === 10000) {
  224. this.init();
  225. this.$message.success(res.message)
  226. } else {
  227. this.$message.error(res.message)
  228. }
  229. })
  230. }).catch(() => {
  231. this.$message({
  232. type: 'info',
  233. message: '已取消删除'
  234. });
  235. })
  236. // delArea()
  237. } else {
  238. this.$message.error('请勾选需要删除的区域');
  239. return;
  240. }
  241. },
  242. onSubmit(formName) {
  243. this.$refs[formName].validate((valid) => {
  244. if (valid) {
  245. if (this.showType) {
  246. // 编辑
  247. let params = {
  248. id: this.form.id,
  249. brandName: this.form.brandName,
  250. mainStream: this.form.mainStream,
  251. assistStream: this.form.assistStream,
  252. streamType: this.form.streamType,
  253. }
  254. editBarand(params).then(res => {
  255. this.reset()
  256. if(res.code === 10000) {
  257. this.init();
  258. this.$message.success(res.message)
  259. } else {
  260. this.$message.error(res.message)
  261. }
  262. })
  263. } else {
  264. // 新增
  265. let params = {
  266. brandName: this.form.brandName,
  267. mainStream: this.form.mainStream,
  268. assistStream: this.form.assistStream,
  269. streamType: this.form.streamType
  270. }
  271. addBarand(params).then(res => {
  272. this.reset();
  273. if(res.code === 10000) {
  274. this.init();
  275. this.$message.success(res.message);
  276. } else {
  277. this.$message.error(res.message)
  278. }
  279. })
  280. }
  281. } else {
  282. console.log('error submit!!');
  283. return false;
  284. }
  285. })
  286. },
  287. reset() {
  288. this.showType = false;
  289. this.dialogVisible = false;
  290. this.form = {
  291. brandName: '',
  292. mainStream: '',
  293. assistStream: '',
  294. streamType: 0,
  295. }
  296. },
  297. del(row) {
  298. let params = {
  299. ids: row.id
  300. }
  301. delBarand(params).then(res =>{
  302. if(res.code === 10000) {
  303. this.init()
  304. this.$message.success(res.message)
  305. } else {
  306. this.$message.error('删除失败')
  307. }
  308. })
  309. }
  310. },
  311. mounted() {
  312. this.init()
  313. }
  314. }
  315. </script>
  316. <style scoped>
  317. .cameraBrand {
  318. width: 100%;
  319. height: 100%;
  320. box-sizing: border-box;
  321. padding: 20px;
  322. }
  323. </style>