index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <materialPlan-search
  5. @search="reload"
  6. :statusOpt="statusOpt"
  7. :activeName="activeName"
  8. ref="searchRef"
  9. >
  10. </materialPlan-search>
  11. <el-button
  12. type="primary"
  13. style="margin: 20px 0"
  14. @click="handleEdit('add')"
  15. >创建计划</el-button
  16. >
  17. <el-tabs v-model="activeName" type="card" @tab-click="handleTabChange">
  18. <el-tab-pane label="未发布" name="first"></el-tab-pane>
  19. <el-tab-pane label="已发布" name="second"></el-tab-pane>
  20. </el-tabs>
  21. <!-- 数据表格 -->
  22. <ele-pro-table
  23. ref="table"
  24. :key="activeName"
  25. :initLoad="false"
  26. :columns="columns"
  27. :datasource="datasource"
  28. :cache-key="`${activeName}materialPlanTable`"
  29. >
  30. <template v-slot:code="{ row }">
  31. <el-link type="primary" :underline="false" @click="goDetail(row)">
  32. {{ row.code }}
  33. </el-link>
  34. </template>
  35. <!-- 操作列 -->
  36. <template v-slot:action="{ row }">
  37. <el-link
  38. type="primary"
  39. :underline="false"
  40. icon="el-icon-truck"
  41. v-if="row.status == 2"
  42. @click="handleOrderPublish(1, row)"
  43. >
  44. 发布工单
  45. </el-link>
  46. <el-link
  47. type="primary"
  48. v-if="row.status == 3"
  49. :underline="false"
  50. icon="el-icon-truck"
  51. @click="handleOrderPublish(2, row)"
  52. >
  53. 重新发布
  54. </el-link>
  55. <el-link
  56. type="primary"
  57. :underline="false"
  58. icon="el-icon-edit"
  59. @click="handleEdit('edit', row)"
  60. >
  61. 修改计划
  62. </el-link>
  63. <el-link
  64. type="primary"
  65. @click="handleDel(row)"
  66. :underline="false"
  67. icon="el-icon-edit"
  68. >
  69. 删除
  70. </el-link>
  71. </template>
  72. </ele-pro-table>
  73. </el-card>
  74. <planEditDialog ref="planEditDialogRef" @success="reload" />
  75. </div>
  76. </template>
  77. <script>
  78. import materialPlanSearch from './components/materialPlan-search.vue';
  79. import planEditDialog from './components/plan-edit-dialog.vue';
  80. import { getList, del } from '@/api/materialPlan/index';
  81. export default {
  82. components: {
  83. planEditDialog,
  84. materialPlanSearch
  85. },
  86. data () {
  87. return {
  88. activeName: 'first',
  89. // 加载状态
  90. loading: false,
  91. pageType: 'add',
  92. dialogTitle: '',
  93. isBindPlan: false,
  94. statusOpt: {
  95. first: [
  96. { label: '所有状态', value: '3,2' },
  97. { label: '待发布', value: '2' },
  98. { label: '发布失败', value: '3' }
  99. ],
  100. second: [
  101. { label: '所有状态', value: '7,4,5,6' },
  102. { label: '待生产', value: '4' },
  103. { label: '生产中', value: '5' },
  104. { label: '已完成', value: '6' },
  105. { label: '已延期', value: '7' }
  106. ]
  107. }
  108. };
  109. },
  110. computed: {
  111. // 表格列配置
  112. columns () {
  113. return [
  114. {
  115. columnKey: 'index',
  116. label: '序号',
  117. type: 'index',
  118. width: 55,
  119. align: 'center',
  120. fixed: 'left'
  121. },
  122. {
  123. slot: 'code',
  124. prop: 'code',
  125. action: 'code',
  126. label: '计划编号',
  127. align: 'center'
  128. },
  129. {
  130. prop: 'materialCode',
  131. label: '编号',
  132. align: 'center'
  133. },
  134. {
  135. prop: 'materialName',
  136. label: '物料名称',
  137. align: 'center'
  138. },
  139. {
  140. prop: 'brandNo',
  141. label: '牌号',
  142. align: 'center'
  143. },
  144. {
  145. prop: 'num',
  146. label:
  147. this.activeName === 'second'
  148. ? '计划生产重量(KG)'
  149. : '生产重量(KG)',
  150. align: 'center'
  151. },
  152. ...(this.activeName === 'second'
  153. ? [
  154. {
  155. prop: 'releaseTime',
  156. label: '已生产重量(KG)',
  157. align: 'center'
  158. }
  159. ]
  160. : []),
  161. // {
  162. // prop: 'produceVersionName',
  163. // label: '生产版本',
  164. // align: 'center',
  165. // showOverflowTooltip: true,
  166. // minWidth: 110
  167. // },
  168. // {
  169. // prop: 'executeUserName',
  170. // label: '工艺版本',
  171. // align: 'center',
  172. // showOverflowTooltip: true,
  173. // minWidth: 110
  174. // },
  175. {
  176. prop: 'deliveryTime',
  177. label: '要求交付日期',
  178. align: 'center'
  179. },
  180. ...(this.activeName === 'second'
  181. ? [
  182. {
  183. prop: 'completeTime',
  184. label: '实际完成时间',
  185. align: 'center'
  186. }
  187. ]
  188. : []),
  189. {
  190. prop: 'status',
  191. label: '状态',
  192. align: 'center',
  193. formatter: (row) => {
  194. const obj = this.statusOpt[this.activeName].find(
  195. (i) => i.value == row.status
  196. );
  197. return obj && obj.label;
  198. }
  199. },
  200. {
  201. prop: 'createUserName',
  202. label: '创建人',
  203. align: 'center'
  204. },
  205. {
  206. prop: 'createTime',
  207. label: '创建时间',
  208. align: 'center'
  209. },
  210. ...(this.activeName === 'second'
  211. ? [
  212. {
  213. prop: 'releaseTime',
  214. label: '发布时间',
  215. align: 'center'
  216. }
  217. ]
  218. : []),
  219. ...(this.activeName === 'first'
  220. ? [
  221. {
  222. columnKey: 'action',
  223. label: '操作',
  224. width: 350,
  225. align: 'center',
  226. resizable: false,
  227. fixed: 'right',
  228. slot: 'action'
  229. }
  230. ]
  231. : [])
  232. ];
  233. }
  234. },
  235. methods: {
  236. /* 表格数据源 */
  237. datasource ({ page, limit, where, order }) {
  238. return getList({
  239. pageNum: page,
  240. size: limit,
  241. ...where
  242. });
  243. },
  244. handleEdit (type, row) {
  245. this.$refs.planEditDialogRef.open(type, row);
  246. },
  247. handleDel ({ id }) {
  248. this.$confirm('确认删除当前数据!', '提示').then(async () => {
  249. await del([id]);
  250. this.$message.success('删除成功!');
  251. this.reload();
  252. });
  253. },
  254. // 发布工单
  255. handleOrderPublish (type, row) {
  256. this.$router.push({
  257. path: '/materialPlan/workOrderPublish',
  258. query: {
  259. type,
  260. id: row.id
  261. }
  262. });
  263. },
  264. handleTabChange () {
  265. this.$refs.searchRef.reset();
  266. },
  267. /* 刷新表格 */
  268. reload (where = {}) {
  269. this.$nextTick(() => {
  270. this.$refs.table.reload({ page: 1, where });
  271. });
  272. },
  273. goDetail (row) {
  274. this.$router.push({
  275. path: '/materialPlan/detail'
  276. });
  277. }
  278. }
  279. };
  280. </script>
  281. <style lang="scss" scoped></style>