detail.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <div class="stockApplyDetail pagePadding">
  3. <div
  4. v-if="powers && powers.length > 0 && powers.some((item) => item == '007')"
  5. >
  6. <p>{{ status }}---{{ powers }}</p>
  7. <div class="detail-page-title">
  8. <span>备货申请编号:</span><span v-if="sitem">{{ sitem.bk_code }}</span>
  9. <el-button
  10. v-if="
  11. powers.some((item) => item === '015') &&
  12. (status === '0' || status === '1' || status === '2')
  13. "
  14. @click="statusConfirm('-1', '作废该条信息')"
  15. type="danger"
  16. plain
  17. class="fr"
  18. :size="'mini'"
  19. style="margin: 0 0 0 12px"
  20. >作废该条信息</el-button
  21. >
  22. <el-button
  23. @click="statusConfirm('0', '取消审核流程')"
  24. plain
  25. class="fr"
  26. type="primary"
  27. :size="'mini'"
  28. v-if="status === '1' && powers.some((item) => item == '014')"
  29. >取消审核流程</el-button
  30. >
  31. </div>
  32. <status-bar
  33. v-if="newTime !== ''"
  34. :newTime="newTime"
  35. :options="statusOptions"
  36. :status="status"
  37. />
  38. <el-tabs v-model="activeTabs">
  39. <el-tab-pane label="新建备库申请单" name="0">
  40. <add-edit
  41. :sitem="sitem"
  42. :id="queryId"
  43. :newTime="newTime"
  44. :type="queryId"
  45. @refresh="initData"
  46. v-if="newTime != ''"
  47. />
  48. </el-tab-pane>
  49. <el-tab-pane label="业务详情" name="1">
  50. <el-collapse v-model="activeNames" style="margin: -18px 0 0 0">
  51. <el-collapse-item name="1" title="备货详情">
  52. <add-edit
  53. :sitem="sitem"
  54. :id="queryId"
  55. :newTime="newTime"
  56. :type="'1'"
  57. @refresh="initData"
  58. v-if="newTime != ''"
  59. />
  60. </el-collapse-item>
  61. <el-collapse-item
  62. name="2"
  63. title="发起审核流程"
  64. v-if="status === '0' && powers.some((item) => item == '012')"
  65. >
  66. <div class="exam-content">
  67. <el-button
  68. type="primary"
  69. class="fr"
  70. :size="'mini'"
  71. @click="statusConfirm('1', '发起审核流程')"
  72. >发起审核流程
  73. </el-button>
  74. </div>
  75. </el-collapse-item>
  76. <el-collapse-item name="3" title="采购反馈" v-if="status !== '0'">
  77. <purchase-back
  78. :sitem="sitem"
  79. :id="queryId"
  80. :newTime="newTime"
  81. v-if="newTime != ''"
  82. @refresh="initData"
  83. />
  84. </el-collapse-item>
  85. <el-collapse-item
  86. name="4"
  87. title="同意采购"
  88. v-if="status === '2' && powers.some((item) => item === '025')"
  89. >
  90. <el-row style="padding: 0 0 20px 0">
  91. <el-col :span="2" offset="20">
  92. <el-button
  93. :disabled="
  94. !(status === '2' && powers.some((item) => item === '025'))
  95. "
  96. type="primary"
  97. size="small"
  98. @click="feeChange('同意反馈', '3')"
  99. >
  100. 同 意
  101. </el-button>
  102. </el-col>
  103. <el-col :span="2">
  104. <el-button
  105. :disabled="
  106. !(status === '2' && powers.some((item) => item === '025'))
  107. "
  108. type="warning"
  109. size="small"
  110. @click="feeChange('拒绝反馈', '4')"
  111. >
  112. 拒 绝
  113. </el-button>
  114. </el-col>
  115. </el-row>
  116. </el-collapse-item>
  117. </el-collapse>
  118. </el-tab-pane>
  119. <el-tab-pane label="审批记录" name="2">
  120. <process-time-line
  121. v-if="newTime !== ''"
  122. :newTime="newTime"
  123. :type="'BHD'"
  124. :orderCode="orderCode"
  125. />
  126. </el-tab-pane>
  127. </el-tabs>
  128. </div>
  129. <div v-else>
  130. <no-auth></no-auth>
  131. </div>
  132. </div>
  133. </template>
  134. <script>
  135. import mixinPage from "@/mixins/elPaginationHandle";
  136. import resToken from "@/mixins/resToken";
  137. import asyncRequest from "@/apis/service/sellOut/stockApply";
  138. import addEdit from "./components/addEdit";
  139. import { mapGetters } from "vuex";
  140. import PurchaseBack from "./components/purchaseBack.vue";
  141. export default {
  142. name: "stockApplyDetail",
  143. mixins: [mixinPage, resToken],
  144. components: {
  145. addEdit,
  146. PurchaseBack,
  147. },
  148. computed: {
  149. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  150. powers() {
  151. let tran =
  152. this.$store.getters.btnList.find(
  153. (item) => item.menu_route == "stockApplyDetail"
  154. ) || {};
  155. if (tran && tran.action && tran.action.length > 0) {
  156. return tran.action;
  157. } else {
  158. return [];
  159. }
  160. },
  161. },
  162. data() {
  163. return {
  164. orderCode: "",
  165. activeTabs: "1",
  166. activeNames: ["0", "1", "2", "3", "4"],
  167. newTime: "",
  168. isDisabled: false,
  169. queryId: "",
  170. queryType: "",
  171. loading: true,
  172. sitem: null,
  173. status: "",
  174. statusOptions: [
  175. { value: "0", label: "待发起审核流程" },
  176. { value: "1", label: "待采购反馈" },
  177. { value: "2", label: "待同意采购" },
  178. { value: "3", label: "已同意采购" },
  179. ],
  180. };
  181. },
  182. mounted() {
  183. const { id, type } = this.$route.query;
  184. this.queryId = id;
  185. this.queryType = type;
  186. if (this.queryType === "add") {
  187. this.sitem = {};
  188. this.getNewTime();
  189. } else {
  190. this.initData();
  191. }
  192. },
  193. methods: {
  194. async feeChange(val, status) {
  195. this.loading = true;
  196. await this.$confirm(`确定要${val}?`, {
  197. confirmButtonText: "确定",
  198. cancelButtonText: "取消",
  199. type: "warning",
  200. })
  201. .then(async () => {
  202. let res = {};
  203. let model = {
  204. id: this.sitem.id,
  205. status,
  206. };
  207. if (status === "3") {
  208. res = await asyncRequest.feeChange(model);
  209. if (res && res.code === 0 && res.data) {
  210. this.getNewTime();
  211. this.$notify({
  212. title: val + "成功",
  213. message: "",
  214. type: "success",
  215. });
  216. this.initData();
  217. } else if (res && res.code >= 100 && res.code <= 104) {
  218. await this.logout();
  219. } else {
  220. }
  221. } else if (status === "4") {
  222. res = await asyncRequest.feeChange(model);
  223. if (res && res.code === 0 && res.data) {
  224. this.getNewTime();
  225. this.$notify({
  226. title: val + "成功",
  227. message: "",
  228. type: "warning",
  229. });
  230. this.initData();
  231. } else if (res && res.code >= 100 && res.code <= 104) {
  232. await this.logout();
  233. } else {
  234. console.log("error");
  235. }
  236. } else {
  237. await this.setStatus(status, message);
  238. }
  239. })
  240. .catch(() => {
  241. console.log("取消");
  242. });
  243. this.loading = false;
  244. },
  245. async initData() {
  246. this.loading = true;
  247. const res = await asyncRequest.detail({ id: this.queryId });
  248. if (res && res.code === 0 && res.data) {
  249. this.sitem = res.data;
  250. this.status = res.data.status;
  251. this.orderCode = res.data.bk_code;
  252. this.getNewTime();
  253. } else if (res && res.code >= 100 && res.code <= 104) {
  254. await this.logout();
  255. } else {
  256. this.sitem = {};
  257. this.status = 0;
  258. }
  259. this.loading = false;
  260. },
  261. // 点击按钮后执行方法
  262. async statusConfirm(status, message) {
  263. await this.$confirm(`确定要${message}?`, {
  264. confirmButtonText: "确定",
  265. cancelButtonText: "取消",
  266. type: "warning",
  267. })
  268. .then(async () => {
  269. if (status === "-1") {
  270. await this.deleteById(message);
  271. } else {
  272. this.isDisabled = true;
  273. await this.setStatus(status, message);
  274. }
  275. })
  276. .catch(() => {
  277. console.log("取消");
  278. });
  279. },
  280. // 作废该条信息
  281. async deleteById(message) {
  282. const res = await asyncRequest.delete({ id: this.queryId });
  283. if (res && res.code === 0) {
  284. this.$notify.success({
  285. title: message + "成功!",
  286. message: "",
  287. });
  288. this.routeGoto("stockApply", {});
  289. } else if (res && res.code >= 100 && res.code <= 104) {
  290. await this.logout();
  291. } else {
  292. this.$message.warning(res.message);
  293. }
  294. },
  295. // 发起备货申请
  296. async setStatus(status, message) {
  297. let model = {
  298. id: this.queryId,
  299. status: status,
  300. };
  301. const res = await asyncRequest.status(model);
  302. this.loading = false;
  303. if (res && res.code === 0) {
  304. this.$notify.success({
  305. title: message + "成功!",
  306. message: "",
  307. });
  308. this.initData();
  309. } else if (res && res.code >= 100 && res.code <= 104) {
  310. await this.logout();
  311. } else {
  312. this.$message.warning(res.message);
  313. }
  314. },
  315. getNewTime() {
  316. this.newTime = new Date().valueOf();
  317. },
  318. },
  319. };
  320. </script>