detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <div>
  3. <basicDetails
  4. ref="details"
  5. :titleText="mainData.name"
  6. :editData="mainData"
  7. :mainAreaData="mainAreaData"
  8. turnPageId="2026051513132402"
  9. idname="sc_workorder_templateid"
  10. ownertable="sc_workorder_template"
  11. tags=""
  12. :tabs="['工序明细', '详细信息']"
  13. :column="4"
  14. @pageChange="pageChange"
  15. @onEditSuccess="queryMainData($route.query.id)"
  16. >
  17. <div slot="tags"></div>
  18. <template slot="customOperation">
  19. <Edit
  20. class="inline-16"
  21. title_btn="编辑"
  22. title_drawer="编辑工单模板"
  23. :data="mainData"
  24. @onSuccess="queryMainData"
  25. ></Edit>
  26. <el-button
  27. v-if="mainData.isused == 0"
  28. type="primary"
  29. size="mini"
  30. :loading="btnLoading"
  31. @click="onToggleUsed(1, '启用')"
  32. >{{ $t('启 用') }}</el-button>
  33. <el-button
  34. v-if="mainData.isused == 1"
  35. type="warning"
  36. size="mini"
  37. :loading="btnLoading"
  38. @click="onToggleUsed(0, '禁用')"
  39. >{{ $t('禁 用') }}</el-button>
  40. <el-button type="danger" @click="onDelete" size="mini">{{ $t(`删 除`) }}</el-button>
  41. </template>
  42. <div slot="slot0">
  43. <taskDetail> </taskDetail>
  44. </div>
  45. <div slot="slot1">
  46. <base-info v-if="detailInfo" :detailInfo="detailInfo"></base-info>
  47. </div>
  48. </basicDetails>
  49. </div>
  50. </template>
  51. <script>
  52. import Edit from '@/Form/terminalWorkBillModule/add';
  53. import BaseInfo from '@/HDrpManagement/projectChange/modules/modules/baseInfo/baseInfo';
  54. import taskDetail from './taskDetail/index';
  55. export default {
  56. name: 'detail',
  57. data() {
  58. return {
  59. mainData: {},
  60. mainAreaData: [],
  61. detailInfo: '',
  62. processDetailList: [],
  63. btnLoading: false,
  64. };
  65. },
  66. components: { Edit, BaseInfo, taskDetail },
  67. provide() {
  68. return {
  69. isEdit: () => this.mainData.isused == 1,
  70. };
  71. },
  72. methods: {
  73. onToggleUsed(value, actionText) {
  74. this.$confirm(this.$t(`确认${actionText}当前工单模板吗`) + '?', this.$t('提示'), {
  75. confirmButtonText: this.$t('确定'),
  76. cancelButtonText: this.$t('取消'),
  77. type: 'warning',
  78. beforeClose: async (action, instance, done) => {
  79. if (action === 'confirm') {
  80. instance.confirmButtonLoading = true;
  81. const res = await this.$api.requested({
  82. id: '2026051513140102',
  83. content: {
  84. sc_workorder_templateid: this.$route.query.id,
  85. isused: value,
  86. },
  87. });
  88. this.tool.showMessage(res, () => {
  89. setTimeout(() => {
  90. instance.confirmButtonLoading = false;
  91. done();
  92. this.queryMainData();
  93. }, 500);
  94. });
  95. } else {
  96. done();
  97. }
  98. },
  99. }).catch(() => {});
  100. },
  101. onDelete() {
  102. this.$confirm(this.$t('是否确认删除此工单模板') + '?', this.$t('提示'), {
  103. confirmButtonText: this.$t('确定'),
  104. cancelButtonText: this.$t('取消'),
  105. type: 'warning',
  106. })
  107. .then(async () => {
  108. const res = await this.$api.requested({
  109. id: '2026051513141202',
  110. content: {
  111. sc_workorder_templateids: [this.$route.query.id],
  112. },
  113. });
  114. if (res.code === 0) {
  115. this.$message.error(res.data[0].errmsg);
  116. } else {
  117. this.$message({
  118. message: this.$t('删除成功'),
  119. type: 'success',
  120. });
  121. this.$store.dispatch('changeDetailDrawer', false);
  122. }
  123. })
  124. .catch(() => {
  125. this.$message({
  126. type: 'info',
  127. message: this.$t('已取消删除'),
  128. });
  129. });
  130. },
  131. async queryMainData() {
  132. const res = await this.$api.requested({
  133. id: 2026051513132402,
  134. content: {
  135. sc_workorder_templateid: this.$route.query.id,
  136. },
  137. });
  138. this.mainData = res.data;
  139. this.changeDataStructure();
  140. console.log('this.mainData', this.mainData);
  141. },
  142. changeDataStructure() {
  143. let that = this;
  144. this.mainAreaData = [
  145. {
  146. label: '模板名称',
  147. value: this.mainData.name,
  148. },
  149. {
  150. label: '工单类型',
  151. value: this.mainData.type,
  152. },
  153. {
  154. label: '是否启用',
  155. value: this.mainData.isused ? '是' : '否',
  156. style: function () {
  157. let style = {};
  158. switch (that.mainData.isused) {
  159. case 1:
  160. style = { color: '#ff0000' };
  161. break;
  162. case 0:
  163. style = { color: '#666666' };
  164. break;
  165. default:
  166. break;
  167. }
  168. return style;
  169. },
  170. },
  171. {
  172. label: '是否后续工单',
  173. value: this.mainData.isworkorder ? '是' : '否',
  174. style: function () {
  175. let style = {};
  176. switch (that.mainData.isworkorder) {
  177. case 1:
  178. style = { color: '#ff0000' };
  179. break;
  180. case 0:
  181. style = { color: '#666666' };
  182. break;
  183. default:
  184. break;
  185. }
  186. return style;
  187. },
  188. },
  189. {
  190. label: '是否积分计算',
  191. value: this.mainData.ispoints ? '是' : '否',
  192. style: function () {
  193. let style = {};
  194. switch (that.mainData.ispoints) {
  195. case 1:
  196. style = { color: '#ff0000' };
  197. break;
  198. case 0:
  199. style = { color: '#666666' };
  200. break;
  201. default:
  202. break;
  203. }
  204. return style;
  205. },
  206. },
  207. ];
  208. this.detailInfo = {
  209. baseInfo: [
  210. {
  211. label: '模板名称',
  212. value: this.mainData.name,
  213. },
  214. {
  215. label: '工单类型',
  216. value: this.mainData.type,
  217. },
  218. {
  219. label: '是否启用',
  220. value: this.mainData.isused ? '是' : '否',
  221. style: function () {
  222. let style = {};
  223. switch (that.mainData.isused) {
  224. case 1:
  225. style = { color: '#ff0000' };
  226. break;
  227. case 0:
  228. style = { color: '#666666' };
  229. break;
  230. default:
  231. break;
  232. }
  233. return style;
  234. },
  235. },
  236. {
  237. label: '是否后续工单',
  238. value: this.mainData.isworkorder ? '是' : '否',
  239. style: function () {
  240. let style = {};
  241. switch (that.mainData.isworkorder) {
  242. case 1:
  243. style = { color: '#ff0000' };
  244. break;
  245. case 0:
  246. style = { color: '#666666' };
  247. break;
  248. default:
  249. break;
  250. }
  251. return style;
  252. },
  253. },
  254. {
  255. label: '是否积分计算',
  256. value: this.mainData.ispoints ? '是' : '否',
  257. style: function () {
  258. let style = {};
  259. switch (that.mainData.ispoints) {
  260. case 1:
  261. style = { color: '#ff0000' };
  262. break;
  263. case 0:
  264. style = { color: '#666666' };
  265. break;
  266. default:
  267. break;
  268. }
  269. return style;
  270. },
  271. },
  272. ],
  273. systemInfo: [
  274. { label: '创建人', value: this.mainData.createby },
  275. { label: '创建时间', value: this.mainData.createdate },
  276. { label: '最近编辑人', value: this.mainData.changeby },
  277. { label: '最近编辑时间', value: this.mainData.changedate },
  278. ],
  279. };
  280. },
  281. // 监听切换数据,上一页,下一页
  282. pageChange(id, rowindex, tabIndex) {
  283. this.flag = false;
  284. tabIndex = this.$route.query.tabIndex;
  285. this.$router.replace({
  286. path: '/serveWorkTaskDetail',
  287. query: { id: id, rowindex: rowindex, tabIndex: tabIndex },
  288. });
  289. this.queryMainData(id);
  290. },
  291. },
  292. mounted() {
  293. this.queryMainData(this.$route.query.id);
  294. },
  295. created() {},
  296. };
  297. </script>
  298. <style scoped></style>