BaseFormLocation.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <a-card :bordered="false" v-show="visible" class="card">
  3. <a-row :gutter="48" style="position:fixed;bottom:150px;z-index:999;display:flex; justify-content: center;width: 90%;">
  4. <a-col :md="48" :sm="48">
  5. <span>
  6. <a-button type="primary" @click="save()">保存</a-button>
  7. <a-button style="margin-left: 8px" type="default" @click="handleCancel()">返回</a-button>
  8. </span>
  9. </a-col>
  10. </a-row>
  11. <div>
  12. <a-table
  13. :columns="columns"
  14. :data-source="modal"
  15. bordered
  16. :defaultExpandAllRows="true"
  17. >
  18. <template v-slot:index="text,record,index">
  19. {{ index+1 }}
  20. </template>
  21. <template v-slot:positionNo="text,record,index">
  22. <div v-if="changeType===1">
  23. {{ text }}
  24. </div>
  25. <div v-else>
  26. <a-input v-if="record.isChild !== 1" style="width: 150px" v-model="record.positionNo" />
  27. <div v-else style="width:300px">
  28. <a-input
  29. disabled
  30. style="width: 50%"
  31. v-model="record.positionNo"/>
  32. <a-button type="primary" @click="handleSbNoSelect(index)">选择</a-button>
  33. </div>
  34. </div>
  35. </template>
  36. <template v-slot:positionName="text,record">
  37. <a-tree-select
  38. v-if="changeType===1"
  39. style="width: 150px"
  40. :dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
  41. :treeData="treeData"
  42. :treeNodeFilterProp="'title'"
  43. :showSearch="true"
  44. v-model="record.positionId"
  45. placeholder="请选择"
  46. >
  47. </a-tree-select>
  48. <span v-else> {{ text }}</span>
  49. </template>
  50. <span slot="status" slot-scope="text">
  51. <badge
  52. :status="DictCache.COLOR.SB_INFO_STATUS[text]"
  53. :text="statusMap[text]" />
  54. </span>
  55. </a-table>
  56. </div>
  57. <sb-position-no-modal ref="sbPositionNoModal" @selected="handleSbNoSelectd"/>
  58. </a-card>
  59. </template>
  60. <script>
  61. import { getSbPositionTree } from '@/api/sb/position'
  62. import SbPositionNoModal from '@/views/sb/info/modules/SbPositionNoModal'
  63. import { batchChanges } from '@/api/sb/info'
  64. export default {
  65. name: 'BaseFillGatherTask',
  66. components: {
  67. SbPositionNoModal
  68. },
  69. data () {
  70. return {
  71. visible: false,
  72. modal: [],
  73. expandedRowKeys: [],
  74. treeData: [],
  75. sbParentOPt: '',
  76. statusMap: {},
  77. changeType: 0,
  78. columns: [
  79. {
  80. title: '序号',
  81. key: 'index',
  82. align: 'center',
  83. width: 50,
  84. scopedSlots: { customRender: 'index' }
  85. },
  86. {
  87. title: '设备名称',
  88. width: 100,
  89. dataIndex: 'name'
  90. },
  91. {
  92. title: '设备编号',
  93. dataIndex: 'no',
  94. width: 120
  95. },
  96. {
  97. title: '设备类型',
  98. dataIndex: 'type',
  99. width: 150,
  100. customRender: (text, record, index) => {
  101. return record.typeName
  102. }
  103. },
  104. {
  105. title: '设备位号',
  106. dataIndex: 'positionNo',
  107. width: 150,
  108. scopedSlots: { customRender: 'positionNo' }
  109. },
  110. {
  111. title: '设备位置',
  112. checked: true,
  113. width: 200,
  114. dataIndex: 'positionName',
  115. scopedSlots: { customRender: 'positionName' }
  116. },
  117. {
  118. title: '状态',
  119. dataIndex: 'status',
  120. width: 100,
  121. scopedSlots: { customRender: 'status' }
  122. }
  123. ]
  124. }
  125. },
  126. props: {
  127. },
  128. created () {
  129. // 下拉框map
  130. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.SB_INFO_STATUS)
  131. getSbPositionTree().then(res => {
  132. this.treeData = res.data
  133. })
  134. },
  135. methods: {
  136. base (record, type) {
  137. this.visible = true
  138. this.changeType = type
  139. this.modal = record.map(item => {
  140. if (item.children.length === 0) item.children = null
  141. return item
  142. })
  143. console.log(this.modal)
  144. console.log(this.changeType)
  145. },
  146. save () {
  147. const params = this.modal.map(item => {
  148. const param = {
  149. sbId: item.id,
  150. changeType: this.changeType,
  151. sbNoId: item.positionNo,
  152. positionId: item.positionId
  153. }
  154. return param
  155. })
  156. batchChanges({ sbChangeRecordDTOList: params }).then(res => {
  157. this.$message.success('修改完成!')
  158. this.handleCancel()
  159. })
  160. console.log(params)
  161. },
  162. handleSbNoSelect (i) {
  163. this.sbParentOPt = i
  164. this.$refs.sbPositionNoModal.base()
  165. },
  166. handleSbNoSelectd (keys, rows) {
  167. console.log(keys, rows)
  168. this.modal[ this.sbParentOPt ].positionNo = rows[0].no
  169. },
  170. handleCancel () {
  171. this.visible = false
  172. this.$emit('ok')
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="less" scoped>
  178. </style>