purInwardRequirement.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. // 采购内转需求
  2. <template>
  3. <div class="steel_inbound">
  4. <div class="sache">
  5. <el-input placeholder="请输入内容" v-model="inputText" clearable>
  6. </el-input>
  7. <el-button type="primary" class="btn">
  8. <i class="el-icon-search"></i>查询
  9. </el-button>
  10. <el-button
  11. type="primary"
  12. class="btn"
  13. @click="toInsert"
  14. v-if="activeName == 'first'"
  15. >
  16. <i class="el-icon-plus"></i>新增
  17. </el-button>
  18. <el-button
  19. type="primary"
  20. class="btn"
  21. @click="Issue"
  22. v-if="activeName == 'first'"
  23. >
  24. <i class="el-icon-download"></i>下发
  25. </el-button>
  26. </div>
  27. <template>
  28. <div>
  29. <el-tabs v-model="activeName">
  30. <el-tab-pane label="未下发" name="first">
  31. <dilTable v-bind.sync="first" @selection-change="selectionChange">
  32. <el-table-column fixed="right" label="操作" width="100">
  33. <template slot-scope="scope">
  34. <el-button
  35. type="text"
  36. size="mini"
  37. @click="deleteRequirement(scope)"
  38. >
  39. 删除
  40. </el-button>
  41. </template>
  42. </el-table-column>
  43. </dilTable>
  44. </el-tab-pane>
  45. <el-tab-pane label="已下发" name="second">
  46. <dilTable v-bind.sync="second" @func="func">
  47. <el-table-column fixed="right" label="操作" width="100">
  48. <template slot-scope="scope">
  49. <el-button
  50. type="text"
  51. size="mini"
  52. @click="stopRequirement(scope)"
  53. >
  54. {{startStop}}
  55. </el-button>
  56. </template>
  57. </el-table-column>
  58. </dilTable>
  59. </el-tab-pane>
  60. </el-tabs>
  61. </div>
  62. </template>
  63. </div>
  64. </template>
  65. <script>
  66. import { getCookie } from "@/utils/util.js";
  67. export default {
  68. data() {
  69. return {
  70. startStop:null,
  71. startStopValue:null,
  72. inputText: "",
  73. first: {
  74. // first请求数据的地址
  75. requestUrl:
  76. "",
  77. selectionType: "select",
  78. mapList: [],
  79. },
  80. second: {
  81. // second请求数据的地址
  82. requestUrl:
  83. "",
  84. },
  85. activeName: "first",
  86. };
  87. },
  88. created(){
  89. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode")=="zidonghuabu"){
  90. this.first.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=0"
  91. this.second.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1"
  92. }else{
  93. this.first.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=0&userId=" + getCookie("orgCode")
  94. this.second.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1&userId=" + getCookie("orgCode")
  95. }
  96. },
  97. methods: {
  98. func(res){
  99. res.list.forEach(e => {
  100. if(e.enable == "未启用"){
  101. this.startStop = "停用"
  102. }else{
  103. this.startStop = "停用"
  104. }
  105. });
  106. },
  107. getRequestUrl(){
  108. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode")=="zidonghuabu"){
  109. this.first.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=0" + "&t=" + new Date()
  110. this.second.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1" + "&t=" + new Date()
  111. }else{
  112. this.first.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=0&userId=" + getCookie("orgCode") + "&t=" + new Date()
  113. this.second.requestUrl = "/api/v1/ams/getPurRequirementList?apiId=431&requirementStatus=1&userId=" + getCookie("orgCode") + "&t=" + new Date()
  114. }
  115. },
  116. selectionChange(selection) {
  117. this.first.mapList = selection;
  118. },
  119. toInsert() {
  120. this.$router.push("/addRequirement");
  121. },
  122. deleteRequirement(scope) {
  123. console.log(scope.row.requirementId)
  124. this.$confirm("是否删除", "提示", {
  125. confirmButtonText: "确定",
  126. cancelButtonText: "取消",
  127. type: "warning",
  128. center: true,
  129. })
  130. .then(() => {
  131. this.axios
  132. .post(
  133. "/api/v1/ams/deleteTruckRequirement/" + scope.row.requirementId
  134. )
  135. .then((res) => {
  136. if (res.data.code == 200) {
  137. this.$message({
  138. type: "success",
  139. message: "删除成功!",
  140. });
  141. this.getRequestUrl()
  142. } else {
  143. this.$message({
  144. message: "删除失败",
  145. type: "warning",
  146. });
  147. }
  148. });
  149. })
  150. .catch(() => {
  151. this.$message({
  152. type: "info",
  153. message: "删除操作已取消!",
  154. });
  155. });
  156. },
  157. stopRequirement(scope){
  158. this.$confirm("是否停用", "提示", {
  159. confirmButtonText: "确定",
  160. cancelButtonText: "取消",
  161. type: "warning",
  162. center: true,
  163. })
  164. .then(() => {
  165. this.axios
  166. .post("/api/v1/ams/changePlanStatus/" + scope.row.planId)
  167. .then((res) => {
  168. if (res.data.code == 200) {
  169. this.$message({
  170. type: "success",
  171. message: "停用成功!",
  172. });
  173. this.getRequestUrl()
  174. } else {
  175. this.$message({
  176. message: "停用失败",
  177. type: "warning",
  178. });
  179. }
  180. });
  181. })
  182. .catch(() => {
  183. this.$message({
  184. type: "info",
  185. message: "取消下发!",
  186. });
  187. });
  188. },
  189. Issue() {
  190. this.$confirm("是否下发", "提示", {
  191. confirmButtonText: "确定",
  192. cancelButtonText: "取消",
  193. type: "warning",
  194. center: true,
  195. })
  196. .then(() => {
  197. this.axios
  198. .post("/api/v1/ams/downRequirement", this.first.mapList)
  199. .then((res) => {
  200. if (res.data.code == 200) {
  201. this.$message({
  202. type: "success",
  203. message: "下发成功!",
  204. });
  205. this.getRequestUrl()
  206. this.activeName = 'second'
  207. } else {
  208. this.$message({
  209. message: "下发失败",
  210. type: "warning",
  211. });
  212. }
  213. });
  214. })
  215. .catch(() => {
  216. this.$message({
  217. type: "info",
  218. message: "取消下发!",
  219. });
  220. });
  221. },
  222. },
  223. };
  224. </script>
  225. <style lang="scss">
  226. .steel_inbound{
  227. .sache{
  228. padding: 1.25rem 0.375rem;
  229. .el-input {
  230. width: 20%;
  231. margin-right: 1.25rem;
  232. }
  233. }
  234. }
  235. </style>