index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <!-- 搜索表单 -->
  5. <user-search @search="reload" />
  6. <!-- 数据表格 -->
  7. <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="id">
  8. <!-- 表头工具栏 -->
  9. <template v-slot:toolbar>
  10. <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon"
  11. @click="openEdit(null)">新增</el-button>
  12. <el-button size="small" type="primary" icon="el-icon-refresh-left" class="ele-btn-icon" @click='refreshData'
  13. :loading="loading">刷新</el-button>
  14. </template>
  15. <template v-slot:code="{ row }">
  16. <el-link type="primary" :underline="false" @click="openDetail(row)"> {{ row.code }}</el-link>
  17. </template>
  18. <!-- 状态列 -->
  19. <template v-slot:status="{ row }">
  20. {{ checkStatus(row) }}
  21. </template>
  22. <template v-slot:routeType="{ row }">
  23. {{ row.routeType == 2 ? '委外' : row.routeType == 1 ? '生产' : row.routeType == 3 ? '质检' : ''}}
  24. </template>
  25. <!-- 操作列 -->
  26. <template v-slot:action="{ row }">
  27. <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row)">
  28. 修改
  29. </el-link>
  30. <el-link type="primary" :underline="false" icon="el-icon-document" @click="openHistory(row)">
  31. 历史版本
  32. </el-link>
  33. <el-popconfirm v-if="row.status != 1" class="ele-action" title="确定要删除当前工序吗?" @confirm="remove(row)">
  34. <template v-slot:reference>
  35. <el-link type="danger" :underline="false" icon="el-icon-delete">
  36. 删除
  37. </el-link>
  38. </template>
  39. </el-popconfirm>
  40. </template>
  41. </ele-pro-table>
  42. </el-card>
  43. <!-- 编辑弹窗 -->
  44. <user-edit :visible.sync="showEdit" :data="current" @done="reload" ref="userEdit" />
  45. <!-- 历史版本弹框 -->
  46. <historyModal ref="historyRefs"></historyModal>
  47. <UserDetail :visible.sync="detailEdit" :data="current" @close="detailEdit = false"></UserDetail>
  48. </div>
  49. </template>
  50. <script>
  51. import UserSearch from './components/user-search.vue';
  52. import UserEdit from './components/user-edit.vue';
  53. import UserDetail from './components/user-detail.vue'
  54. import historyModal from './components/historyModal.vue'
  55. import route from '@/api/technology/route';
  56. export default {
  57. name: 'technologyRoute',
  58. components: {
  59. UserSearch,
  60. UserEdit,
  61. UserDetail,
  62. historyModal
  63. },
  64. data() {
  65. return {
  66. // 表格列配置
  67. columns: [
  68. {
  69. prop: 'code',
  70. label: '工艺路线组编码',
  71. showOverflowTooltip: true,
  72. align: 'center',
  73. minWidth: 110,
  74. slot: 'code',
  75. },
  76. {
  77. prop: 'name',
  78. label: '工艺路线名称',
  79. showOverflowTooltip: true,
  80. align: 'center',
  81. minWidth: 110
  82. },
  83. {
  84. prop: 'version',
  85. label: '工艺路线版本',
  86. align: 'center',
  87. showOverflowTooltip: true,
  88. minWidth: 110
  89. },
  90. {
  91. prop: 'produceVersionName',
  92. label: '生产版本',
  93. align: 'center',
  94. showOverflowTooltip: true
  95. },
  96. {
  97. prop: 'status',
  98. label: '状态',
  99. align: 'center',
  100. slot: 'status',
  101. showOverflowTooltip: true,
  102. minWidth: 110
  103. },
  104. {
  105. slot: 'routeType',
  106. label: '类型',
  107. align: 'center',
  108. showOverflowTooltip: true
  109. },
  110. {
  111. slot: 'factoryName',
  112. label: '所属工厂',
  113. align: 'center',
  114. showOverflowTooltip: true
  115. },
  116. {
  117. columnKey: 'action',
  118. label: '操作',
  119. width: 220,
  120. align: 'left',
  121. resizable: false,
  122. slot: 'action',
  123. }
  124. ],
  125. // 表格选中数据
  126. selection: [],
  127. // 当前编辑数据
  128. current: null,
  129. // 是否显示编辑弹窗
  130. showEdit: false,
  131. detailEdit: false,
  132. statusList: [
  133. { label: '草稿', value: -1 },
  134. { label: '失效', value: 0 },
  135. { label: '生效', value: 1 }
  136. ],
  137. loading: false
  138. };
  139. },
  140. methods: {
  141. /* 表格数据源 */
  142. async datasource({ page, limit, where, order }) {
  143. const res = await route.list({
  144. ...where,
  145. ...order,
  146. pageNum: page,
  147. size: limit
  148. });
  149. return res;
  150. },
  151. checkStatus(row) {
  152. let obj = this.statusList.find((it) => it.value == row.status);
  153. return obj.label;
  154. },
  155. /* 刷新表格 */
  156. reload(where) {
  157. this.$refs.table.reload({ page: 1, where: where });
  158. },
  159. /* 打开编辑弹窗 */
  160. openEdit(row) {
  161. this.current = row;
  162. this.showEdit = true;
  163. this.$refs.userEdit.$refs.form &&
  164. this.$refs.userEdit.$refs.form.clearValidate();
  165. },
  166. /* 打开历史版本 */
  167. openHistory(row) {
  168. this.$refs.historyRefs.open(row)
  169. },
  170. /* 删除 */
  171. remove(row) {
  172. const loading = this.$loading({ lock: true });
  173. route
  174. .delete(row.id)
  175. .then((msg) => {
  176. loading.close();
  177. this.$message.success('删除' + msg);
  178. this.reload();
  179. })
  180. .catch((e) => {
  181. loading.close();
  182. // this.$message.error(e.message);
  183. });
  184. },
  185. /* 批量删除 */
  186. removeBatch() {
  187. if (!this.selection.length) {
  188. this.$message.error('请至少选择一条数据');
  189. return;
  190. }
  191. this.$confirm('确定要删除选中的工序吗?', '提示', {
  192. type: 'warning'
  193. })
  194. .then(() => {
  195. const loading = this.$loading({ lock: true });
  196. producetask
  197. .delete(this.selection.map((d) => d.id))
  198. .then((msg) => {
  199. loading.close();
  200. this.$message.success('删除' + msg);
  201. this.reload();
  202. })
  203. .catch((e) => {
  204. loading.close();
  205. // this.$message.error(e.message);
  206. });
  207. })
  208. .catch(() => { });
  209. },
  210. // 刷新数据
  211. refreshData() {
  212. this.loading = true;
  213. route.syncRouting().then(res => {
  214. if (res == '0') {
  215. this.loading = false;
  216. this.$message.success('数据刷新成功!')
  217. this.reload()
  218. }
  219. })
  220. .catch((e) => {
  221. this.loading = false;
  222. });
  223. },
  224. openDetail(row) {
  225. this.current = row
  226. this.detailEdit = true
  227. },
  228. }
  229. };
  230. </script>