register.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="hui-flex">
  3. <div class="hui-flex-box yui-tree-box">
  4. <div class="hui-left-tree">
  5. <div class="hui-left-tree-title">
  6. <svg-icon name="zhuangshi" width="16" height="20"></svg-icon>
  7. <span class="hui-left-tree-sub">资产列表</span>
  8. </div>
  9. <div class="hui-left-tree-content">
  10. <el-collapse>
  11. <el-collapse-item v-for="item in treeData" :key="item.id">
  12. <template slot="title">
  13. <i class="iconfont huifont-shuzhuangcaidantubiao"></i>
  14. <span class="el-collapse-name">{{item.name}}</span>
  15. </template>
  16. <div>
  17. <el-tree :data="item.children" :props="defaultProps" :expand-on-click-node="false">
  18. </el-tree>
  19. </div>
  20. </el-collapse-item>
  21. </el-collapse>
  22. </div>
  23. </div>
  24. <div class="hui-tree-content">
  25. <div class="hui-flex hui-content box-background">
  26. <div class="hui-content-title">
  27. <div class="hui-title-item active">资产登记</div>
  28. </div>
  29. <div class="hui-flex-box hui-flex hui-table">
  30. <div class="hui-content-insert">
  31. <el-button type="primary" size="medium" @click="insert">新增登记</el-button>
  32. </div>
  33. <div class="hui-flex-box">
  34. <el-table :data="tableData" row-key="id" border height="100%">
  35. <el-table-column label="序号" width="50">
  36. <template slot-scope="scope">
  37. <div style="text-align: center;">{{scope.$index + 1}}</div>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="资产名称" prop="name"></el-table-column>
  41. <el-table-column label="单位工程" prop="projectItemName"></el-table-column>
  42. <el-table-column label="具体位置" prop="projectItemTargetName"></el-table-column>
  43. <el-table-column label="创建者" prop="createdByUserName"></el-table-column>
  44. <el-table-column label="状态">
  45. <template slot-scope="scope">
  46. <div v-if="!scope.row.state" class="hui-state">
  47. <span class="hui-state-bage hui-state-primary"></span>
  48. <span class="hui-state-label">待生成</span>
  49. </div>
  50. <div v-if="scope.row.state == -1 || scope.row.state == 1" class="hui-state">
  51. <span class="hui-state-bage hui-state-primary"></span>
  52. <span class="hui-state-label">待审核</span>
  53. </div>
  54. <div v-if="scope.row.state == 2" class="hui-state">
  55. <span class="hui-state-bage hui-state-info"></span>
  56. <span class="hui-state-label">审核中</span>
  57. </div>
  58. <div v-if="scope.row.state == 3" class="hui-state">
  59. <span class="hui-state-bage hui-state-success"></span>
  60. <span class="hui-state-label">通过</span>
  61. </div>
  62. <div v-if="scope.row.state == 4" class="hui-state">
  63. <span class="hui-state-bage hui-state-error"></span>
  64. <span class="hui-state-label">未通过</span>
  65. </div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="操作" width="150">
  69. <template slot-scope="scope">
  70. <div class="hui-table-operation">
  71. <span class="table-operation" @click="lookFlow(scope.row)">
  72. 详情
  73. </span>
  74. <span class="table-operation" v-if="!scope.row.projectFlowId"
  75. @click="updateFlow(scope.row)">
  76. 编辑
  77. </span>
  78. <span class="table-operation" v-if="!scope.row.projectFlowId"
  79. @click="deleteFlow(scope.row)">
  80. 删除
  81. </span>
  82. </div>
  83. </template>
  84. </el-table-column>
  85. <template slot="empty">
  86. <empty description="暂无数据"></empty>
  87. </template>
  88. </el-table>
  89. </div>
  90. <div class="hui-content-pagination">
  91. <el-pagination :pager-count="9" layout="prev, pager, next" :total="totalCount"
  92. @current-change="currentChange">
  93. </el-pagination>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <el-dialog :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="1200px" :append-to-body="true">
  100. <flow-form v-if="visible" :isUpdate="isUpdate" @callback="callback" :detailId="detailId"
  101. :flowType="flowType">
  102. </flow-form>
  103. </el-dialog>
  104. <el-drawer title="流程详情" :visible.sync="drawer" :size="400" :append-to-body="true">
  105. <flow-detail v-if="drawer" @callback="callback" :detailId="detailId"></flow-detail>
  106. </el-drawer>
  107. </div>
  108. </template>
  109. <script>
  110. import {
  111. initDevicePartList,
  112. getDevicePartList,
  113. getFlowList,
  114. deleteFlow
  115. } from '@/httpApi/property'
  116. import flowForm from '@/components/flow/flowForm'
  117. import flowDetail from '@/components/flow/flowDetail'
  118. export default {
  119. data() {
  120. return {
  121. flowType: 1,
  122. tableData: [],
  123. currPage: 1,
  124. pageSize: 10,
  125. totalCount: 0,
  126. treeData: [],
  127. defaultProps: {
  128. children: 'children',
  129. label: 'name'
  130. },
  131. visible: false,
  132. isUpdate: false,
  133. detailId: '',
  134. drawer: false
  135. }
  136. },
  137. created() {
  138. this.initDeviceList();
  139. this.init();
  140. },
  141. methods: {
  142. init() {
  143. getFlowList(this.currPage, this.pageSize, {
  144. projectId: this.$store.getters.project.id,
  145. flowType: this.flowType
  146. }).then(res => {
  147. if (res.state) {
  148. this.tableData = res.data.dataList.map(node => {
  149. node = Object.assign(node, JSON.parse(node.flowData));
  150. return node;
  151. });;
  152. this.totalCount = res.data.totalCount;
  153. }
  154. })
  155. },
  156. initDeviceList() {
  157. getDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id).then(res => {
  158. if (res.state) {
  159. if (res.data.length === 0) {
  160. initDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id)
  161. .then(res => {
  162. if (res.state) this.init();
  163. })
  164. } else {
  165. this.treeData = res.data;
  166. this.returnChildren(this.treeData);
  167. }
  168. }
  169. })
  170. },
  171. returnChildren(data) {
  172. data.forEach(item => {
  173. if (item.children && item.deviceList) {
  174. let obj = item.deviceList.map(res => {
  175. res['deviceId'] = res.id;
  176. res['id'] = -res.id;
  177. return res;
  178. })
  179. item.children = item.children.concat(obj);
  180. }
  181. if (item.children && item.children.length > 0) this.returnChildren(item.children);
  182. });
  183. },
  184. currentChange(currPage) {
  185. this.currPage = currPage;
  186. this.init();
  187. },
  188. insert() {
  189. this.visible = true;
  190. this.isUpdate = false;
  191. },
  192. lookFlow(val) {
  193. this.detailId = val.id;
  194. this.drawer = true;
  195. },
  196. updateFlow(val) {
  197. this.detailId = val.id;
  198. this.isUpdate = true;
  199. this.visible = true;
  200. },
  201. deleteFlow(val) {
  202. this.$confirm('确定要删除该流程?', () => {
  203. deleteFlow(val.id).then(res => {
  204. if (res.state) {
  205. this.$message.success('操作成功');
  206. this.init();
  207. }
  208. })
  209. });
  210. },
  211. callback(type) {
  212. this.visible = false;
  213. if (type === 'init') this.init();
  214. }
  215. },
  216. components: {
  217. flowForm,
  218. flowDetail
  219. },
  220. }
  221. </script>
  222. <style lang="scss"></style>