routingDialog.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <el-dialog
  3. title="工艺路线"
  4. v-if="visible"
  5. :visible.sync="visible"
  6. :before-close="handleClose"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. append-to-body
  10. width="70%"
  11. >
  12. <div class="ele-body">
  13. <el-card shadow="never">
  14. <!-- 搜索表单 -->
  15. <el-form
  16. label-width="120px"
  17. class="ele-form-search"
  18. @keyup.enter.native="search"
  19. @submit.native.prevent
  20. >
  21. <el-row>
  22. <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
  23. <el-form-item label="工艺路线组编码:">
  24. <el-input
  25. clearable
  26. v-model.trim="where.code"
  27. placeholder="请输入"
  28. />
  29. </el-form-item>
  30. </el-col>
  31. <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
  32. <el-form-item label="工艺路线名称:">
  33. <el-input
  34. clearable
  35. v-model.trim="where.name"
  36. placeholder="请输入"
  37. />
  38. </el-form-item>
  39. </el-col>
  40. <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
  41. <el-form-item label="生产版本:">
  42. <el-select
  43. v-model.trim="where.produceVersionId"
  44. filterable
  45. placeholder="请选择"
  46. :style="{ width: '100%' }"
  47. >
  48. <el-option
  49. v-for="item in versionList"
  50. :key="item.code"
  51. :label="item.code + '-' + item.name"
  52. :value="item.id"
  53. >
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. </el-col>
  58. <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 5 }">
  59. <el-form-item label="状态:" label-width="70px">
  60. <el-select
  61. v-model.trim="where.status"
  62. filterable
  63. placeholder="请选择"
  64. >
  65. <el-option
  66. v-for="item in statusList"
  67. :key="item.value"
  68. :label="item.label"
  69. :value="item.value"
  70. >
  71. </el-option>
  72. </el-select>
  73. </el-form-item>
  74. </el-col>
  75. <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
  76. <el-form-item label-width="20px">
  77. <el-button
  78. type="primary"
  79. icon="el-icon-search"
  80. class="ele-btn-icon"
  81. @click="search"
  82. >
  83. 查询
  84. </el-button>
  85. <el-button @click="reset">重置</el-button>
  86. </el-form-item>
  87. </el-col>
  88. </el-row>
  89. </el-form>
  90. <!-- 数据表格 -->
  91. <ele-pro-table
  92. ref="table"
  93. :columns="columns"
  94. :datasource="datasource"
  95. :selection.sync="selection"
  96. row-key="id"
  97. >
  98. <template v-slot:code="{ row }">
  99. <el-link type="primary" :underline="false" @click="openDetail(row)">
  100. {{ row.code }}</el-link
  101. >
  102. </template>
  103. <!-- 状态列 -->
  104. <template v-slot:status="{ row }">
  105. {{ checkStatus(row) }}
  106. </template>
  107. <template v-slot:routeType="{ row }">
  108. {{ row.routeType == 2 ? '委外' : '生产' }}
  109. </template>
  110. </ele-pro-table>
  111. </el-card>
  112. <div class="btns">
  113. <el-button type="primary" size="small" @click="selected"
  114. >选择</el-button
  115. >
  116. <el-button size="small" @click="handleClose">关闭</el-button>
  117. </div>
  118. <UserDetail
  119. :visible.sync="detailEdit"
  120. :data="current"
  121. @close="detailEdit = false"
  122. ></UserDetail>
  123. </div>
  124. </el-dialog>
  125. </template>
  126. <script>
  127. import {
  128. workingProcedureUpdate,
  129. workingProcedureSave
  130. } from '@/api/material/BOM';
  131. import { pageList } from '@/api/technology/version/version.js';
  132. import UserDetail from './user-detail.vue';
  133. import route from '@/api/technology/route';
  134. export default {
  135. name: 'technologyRoute',
  136. components: {
  137. UserDetail
  138. },
  139. data() {
  140. return {
  141. visible: false,
  142. selection: [],
  143. versionList: [],
  144. where: {},
  145. // 表格列配置
  146. columns: [
  147. {
  148. columnKey: 'selection',
  149. type: 'selection',
  150. width: 45,
  151. align: 'center',
  152. reserveSelection: true,
  153. selectable: (row, index) => {
  154. return this.tableData.processRoute
  155. ? !this.tableData.processRoute.list.some(
  156. (it) => it.id == row.id
  157. )
  158. : true;
  159. },
  160. fixed: 'left'
  161. },
  162. {
  163. prop: 'code',
  164. label: '工艺路线组编码',
  165. showOverflowTooltip: true,
  166. align: 'center',
  167. minWidth: 110,
  168. slot: 'code'
  169. },
  170. {
  171. prop: 'name',
  172. label: '工艺路线名称',
  173. showOverflowTooltip: true,
  174. align: 'center',
  175. minWidth: 110
  176. },
  177. {
  178. prop: 'version',
  179. label: '工艺路线版本',
  180. align: 'center',
  181. showOverflowTooltip: true,
  182. minWidth: 110
  183. },
  184. {
  185. prop: 'produceVersionName',
  186. label: '生产版本',
  187. align: 'center',
  188. showOverflowTooltip: true
  189. },
  190. {
  191. prop: 'status',
  192. label: '状态',
  193. align: 'center',
  194. slot: 'status',
  195. showOverflowTooltip: true,
  196. minWidth: 110
  197. },
  198. {
  199. slot: 'routeType',
  200. label: '类型',
  201. align: 'center',
  202. showOverflowTooltip: true
  203. }
  204. ],
  205. // 表格选中数据
  206. selection: [],
  207. // 当前编辑数据
  208. current: null,
  209. // 是否显示编辑弹窗
  210. showEdit: false,
  211. detailEdit: false,
  212. statusList: [
  213. { label: '草稿', value: -1 },
  214. { label: '失效', value: 0 },
  215. { label: '生效', value: 1 }
  216. ],
  217. loading: false
  218. };
  219. },
  220. computed: {
  221. // 是否开启响应式布局
  222. styleResponsive() {
  223. return this.$store.state.theme.styleResponsive;
  224. }
  225. },
  226. created() {
  227. this.getVersionList();
  228. },
  229. methods: {
  230. reset() {
  231. this.where = {};
  232. this.search();
  233. },
  234. handleClose() {
  235. this.visible = false;
  236. },
  237. open(treeData, tableData) {
  238. this.treeData = treeData;
  239. if (
  240. Object.prototype.hasOwnProperty.call(tableData, 'processRoute') &&
  241. Object.prototype.hasOwnProperty.call(tableData.processRoute, 'list')
  242. ) {
  243. this.tableData = tableData;
  244. } else {
  245. this.tableData = tableData;
  246. this.tableData['processRoute'] = { list: [] }
  247. }
  248. this.visible = true;
  249. },
  250. selected() {
  251. let routingId = this.selection.map((it) => it.id);
  252. route.getProcessById(routingId).then((data) => {
  253. console.log(this.tableData);
  254. if (this.tableData.taskParam) {
  255. let newArr = [];
  256. for (let i = 0; i < data.length; i++) {
  257. let isHas = false;
  258. for (let j = 0; j < this.tableData.taskParam.length; j++) {
  259. if (data[i].sourceTaskId == this.tableData.taskParam[j].sourceTaskId) {
  260. isHas = true;
  261. break;
  262. }
  263. }
  264. if (!isHas) {
  265. newArr.push(data[i]);
  266. }
  267. }
  268. workingProcedureUpdate({
  269. id: this.tableData.id,
  270. categoryId: this.treeData.categoryId,
  271. bomCategoryId: this.treeData.id,
  272. categoryCode: this.treeData.categoryCode,
  273. processRoute: {
  274. list: this.tableData.processRoute.list.concat(this.selection)
  275. },
  276. taskParam: this.tableData.taskParam.concat(newArr)
  277. }).then(() => {
  278. this.$emit('reload');
  279. this.visible = false;
  280. });
  281. } else {
  282. workingProcedureSave({
  283. categoryId: this.treeData.categoryId,
  284. bomCategoryId: this.treeData.id,
  285. categoryCode: this.treeData.categoryCode,
  286. processRoute: {
  287. list: this.selection
  288. },
  289. taskParam: data.map((item) => {
  290. return {
  291. ...item,
  292. versions: this.treeData.versions,
  293. status: this.treeData.status
  294. };
  295. })
  296. }).then(() => {
  297. this.$emit('reload');
  298. this.visible = false;
  299. });
  300. }
  301. });
  302. },
  303. async getVersionList() {
  304. const res = await pageList({
  305. pageNum: 1,
  306. size: 100
  307. });
  308. this.versionList = res.list;
  309. },
  310. search() {
  311. this.reload(this.where);
  312. },
  313. /* 表格数据源 */
  314. async datasource({ page, limit, where, order }) {
  315. const res = await route.list({
  316. ...where,
  317. ...order,
  318. pageNum: page,
  319. size: limit
  320. });
  321. return res;
  322. },
  323. checkStatus(row) {
  324. let obj = this.statusList.find((it) => it.value == row.status);
  325. return obj.label;
  326. },
  327. /* 刷新表格 */
  328. reload(where) {
  329. this.$refs.table.reload({ page: 1, where: where });
  330. },
  331. openDetail(row) {
  332. this.current = row;
  333. this.detailEdit = true;
  334. }
  335. }
  336. };
  337. </script>
  338. <style lang="scss" scoped>
  339. .btns {
  340. text-align: center;
  341. padding: 10px 0;
  342. }
  343. </style>