index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div>
  3. <FullPage title='芯片列表'
  4. :list='list'
  5. @init='init'
  6. :loading='loading'
  7. @searchData='init'
  8. @changePage='changePage'
  9. @changeSize='changeSize'
  10. @selectTable='selectTable'
  11. :tableColums='tableColums'
  12. :tableData='tableData'
  13. :pageIndex='pageIndex'
  14. :total='total'>
  15. <div slot="titleButton">
  16. <Button v-if='persimissionData["批量删除"]||persimissionData.all'
  17. @click="delItems(selects)"
  18. type='error'
  19. ghost>批量删除</Button>
  20. </div>
  21. <template slot='set'
  22. slot-scope='{row}'>
  23. <div class="table-set">
  24. <a v-if='persimissionData["绑定详情"]||persimissionData.all'
  25. @click="chipDetails(row)"
  26. class="map-margin">绑定详情</a>
  27. <!-- <a v-if="(row.status!=2)&&(persimissionData['解绑']||persimissionData.all)"
  28. @click="unBind(row)"
  29. class="map-margin">解绑</a> -->
  30. <a v-if='persimissionData["删除"]||persimissionData.all'
  31. @click="delItems(row)"
  32. class="map-margin">删除</a>
  33. </div>
  34. </template>
  35. <div>
  36. <Modal class-name="vertical-center-modal"
  37. @on-ok="postInfo"
  38. title="芯片详情"
  39. v-model="showModal"
  40. :width="380"
  41. @on-visible-change='vivibleModal'>
  42. <Form :label-width="130">
  43. <FormItem label="项目地址:">{{classInfo.address}}</FormItem>
  44. <FormItem label="房间号:">{{classInfo.house}}</FormItem>
  45. <FormItem label="产品:">{{classInfo.product_title}}</FormItem>
  46. <FormItem label="位置:">{{classInfo.position}}</FormItem>
  47. <FormItem label="部件名称:">{{classInfo.part_title}}</FormItem>
  48. <FormItem label="是否绑定部件:">{{classInfo.label == 1 ? '是' : '否'}}</FormItem>
  49. <FormItem label="零部件名称:">{{classInfo.sub_part}}</FormItem>
  50. <FormItem label="是否绑定零部件:">{{classInfo.sub_is_tag == 1 ? '是' : '否'}}</FormItem>
  51. </Form>
  52. <div slot="footer"></div>
  53. </Modal>
  54. </div>
  55. </FullPage>
  56. </div>
  57. </template>
  58. <script>
  59. import { mapState } from 'vuex'
  60. export default {
  61. data () {
  62. return {
  63. list: [
  64. {
  65. title: '是否绑定', name: 'Select', value: '', serverName: 'status',disabled:true,
  66. option: [
  67. { label: '是', value: 1 },
  68. { label: '否', value: 0 }
  69. ]
  70. },
  71. { title: '芯片编号', name: 'Input', value: '', serverName: 'tag', placeholder: '请输入芯片编号' },
  72. ],
  73. tableColums: [
  74. { type: 'selection', align: 'center', width: 100, fixed: 'left' },
  75. { title: '序号', type: 'index', align: 'center', width: '100', key: '' },
  76. // {title:'ID',align:'center',key:'id',width:'100'},
  77. { title: '芯片编号', align: 'center', key: 'tag' },
  78. // {
  79. // title: '是否绑定', align: 'center', key: 'pr_id',
  80. // render: (h, params) => h('span', params.row.status == 0 ? '未绑定' : (params.row.status == 1 ? '已绑定' : '已解绑'))
  81. // },
  82. { title: '操作', align: 'center', slot: 'set', width: '200' },
  83. ],
  84. tableData: [],
  85. pageIndex: 1,
  86. pageSize: 10,
  87. total: 0,
  88. showModal: false,
  89. showType: 1,
  90. classInfo: {},
  91. proxyObj: {},
  92. loading: false,
  93. add_chip: true,
  94. selects: [],
  95. }
  96. },
  97. computed: {
  98. ...mapState(['persimissionData']),
  99. },
  100. methods: {
  101. init (row) {
  102. this.pageIndex = 1
  103. row.page_index = this.pageIndex;
  104. row.page_size = this.pageSize;
  105. this.proxyObj = row;
  106. this.getData(row)
  107. },
  108. getData (row) {
  109. this.loading = true;
  110. this.axios('/api/tag_list', { params: row }).then(res => {
  111. this.loading = false;
  112. this.tableData = res.data.data;
  113. this.total = res.data.total;
  114. })
  115. },
  116. changePage (e) {
  117. this.pageIndex = e;
  118. this.proxyObj.page_index = this.pageIndex;
  119. this.getData(this.proxyObj);
  120. },
  121. changeSize (e) {
  122. this.pageSize = e;
  123. this.proxyObj.page_size = this.pageSize;
  124. this.getData(this.proxyObj);
  125. },
  126. chipDetails (obj) {
  127. this.showModal = true;
  128. this.axios('/api/tag_detail', { params: { id: obj.id } })
  129. .then(res => {
  130. if (res.code == 200) {
  131. this.classInfo = res.data
  132. }
  133. })
  134. },
  135. postInfo () {
  136. },
  137. vivibleModal (e) {
  138. if (!e) { this.classInfo = {}; }
  139. },
  140. delItems (row) {
  141. let tags;
  142. if (Array.isArray(row)) {
  143. if (row.length < 1) { return this.$Message.warning('请选择') }
  144. tags = row.reduce((pre, cur, n) => {
  145. return pre += `${cur.tag}${n == row.length - 1 ? '' : ','}`
  146. }, '')
  147. } else {
  148. tags = row.tag
  149. }
  150. this.confirmDelete({
  151. content: '确认删除么?',
  152. then: () => {
  153. this.axios.post('/api/tag_del', { tag: tags, state: 0 }).then(res => {
  154. if (res.code == 200) {
  155. this.$Message.success(res.msg)
  156. this.getData(this.proxyObj)
  157. }
  158. })
  159. }
  160. })
  161. },
  162. addChip () {
  163. this.add_chip = true;
  164. },
  165. unBind (row) {
  166. this.confirmDelete({
  167. content: '确认解绑么?',
  168. type: 'primary',
  169. then: () => {
  170. this.axios.post('/api/tag_unbind', { tag: row.tag, state: 0 }).then(res => {
  171. if (res.code == 200) {
  172. this.$Message.success(res.msg)
  173. this.getData(this.proxyObj)
  174. }
  175. })
  176. }
  177. })
  178. },
  179. selectTable (result) {
  180. this.selects = result;
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .nav {
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. }
  191. </style>