requirement.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // 提出需求
  2. <template>
  3. <div class="inwardRequirement">
  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="toInsert2"
  14. v-if="activeName == 'first'"
  15. >
  16. <i class="el-icon-plus"></i>新增
  17. </el-button>
  18. </div>
  19. <template>
  20. <div>
  21. <el-tabs v-model="activeName" @tab-click="handleClick">
  22. <el-tab-pane label="未下发" name="first">
  23. <dilTable v-bind.sync="first" @selection-change="selectionChange" ref="table1">
  24. <el-table-column fixed="right" label="操作" width="120">
  25. <template slot-scope="scope">
  26. <el-button
  27. type="text"
  28. size="mini"
  29. @click="deleteRequirement(scope)"
  30. >
  31. 删除
  32. </el-button>
  33. </template>
  34. </el-table-column>
  35. </dilTable>
  36. </el-tab-pane>
  37. <el-tab-pane label="已下发" name="second">
  38. <dilTable v-bind.sync="second" ref="table">
  39. <el-table-column fixed="right" label="操作" width="80">
  40. <template slot-scope="scope">
  41. <el-button type="text" size="mini" @click="getRequirementOrder(scope)">运单</el-button>
  42. </template>
  43. </el-table-column>
  44. </dilTable>
  45. </el-tab-pane>
  46. </el-tabs>
  47. </div>
  48. </template>
  49. </div>
  50. </template>
  51. <script>
  52. import { getCookie } from "@/utils/util.js";
  53. export default {
  54. data() {
  55. return {
  56. inputText: "",
  57. orgCode:"",
  58. first: {
  59. // first请求数据的地址
  60. requestUrl:
  61. "",
  62. selectionType: "select",
  63. mapList: [],
  64. },
  65. second: {
  66. // second请求数据的地址
  67. requestUrl:
  68. "",
  69. },
  70. tableData: [],
  71. tableData1: [
  72. {
  73. materialCount : 100
  74. }
  75. ],
  76. activeName: "first",
  77. };
  78. },
  79. created(){
  80. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode") == "zidonghuabu"){
  81. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0"
  82. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1"
  83. }else{
  84. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&orgCode=" + getCookie("orgCode")
  85. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&orgCode=" + getCookie("orgCode")
  86. }
  87. },
  88. methods: {
  89. //查看需求下面的运单
  90. getRequirementOrder(scope){
  91. this.$router.push(
  92. "/getRequirementOrder/" + scope.row.requirementId
  93. );
  94. },
  95. handleClick(tab, event) {
  96. this.getRequestUrl()
  97. },
  98. getRequestUrl(){
  99. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode") == "zidonghuabu"){
  100. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&i=" + new Date()
  101. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&i=" + new Date()
  102. }else{
  103. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&orgCode=" + getCookie("orgCode") + "&i=" + new Date()
  104. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&orgCode=" + getCookie("orgCode") + "&i=" + new Date()
  105. }
  106. },
  107. selectionChange(selection) {
  108. this.first.mapList = selection;
  109. },
  110. toInsert2() {
  111. this.$router.push("/addRequirement2");
  112. },
  113. updateRequirement(scope) {
  114. this.$router.push(
  115. "/updateRequirement/" + scope.row.requirementId
  116. );
  117. },
  118. deleteRequirement(scope) {
  119. this.$confirm("是否删除", "提示", {
  120. confirmButtonText: "确定",
  121. cancelButtonText: "取消",
  122. type: "warning",
  123. center: true,
  124. })
  125. .then(() => {
  126. this.axios
  127. .post(
  128. "/api/v1/ams/deleteTruckRequirement/" + scope.row.requirementId
  129. )
  130. .then((res) => {
  131. if (res.data.code == 200) {
  132. this.$message({
  133. type: "success",
  134. message: "删除成功!",
  135. });
  136. this.getRequestUrl()
  137. } else {
  138. this.$message({
  139. message: "删除失败",
  140. type: "warning",
  141. });
  142. }
  143. });
  144. })
  145. .catch(() => {
  146. this.$message({
  147. type: "info",
  148. message: "删除操作已取消!",
  149. });
  150. });
  151. },
  152. Issue() {
  153. console.log(this.first.mapList);
  154. if(this.first.mapList.length == 0){
  155. this.$message.warning("请选择需求")
  156. return
  157. }
  158. // 权限控制,判断用户是否属于轧钢厂下面的车间
  159. this.$confirm("是否下发", "提示", {
  160. confirmButtonText: "确定",
  161. cancelButtonText: "取消",
  162. type: "warning",
  163. center: true,
  164. })
  165. .then(() => {
  166. this.axios
  167. .post("/api/v1/ams/downRequirement", this.first.mapList)
  168. .then((res) => {
  169. if (res.data.code == 200) {
  170. this.$message({
  171. type: "success",
  172. message: "下发成功!",
  173. });
  174. this.getRequestUrl()
  175. this.activeName = 'second'
  176. } else {
  177. this.$message({
  178. message: "下发失败",
  179. type: "warning",
  180. });
  181. }
  182. });
  183. })
  184. .catch(() => {
  185. this.$message({
  186. type: "info",
  187. message: "取消下发!",
  188. });
  189. });
  190. },
  191. },
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .inwardRequirement{
  196. margin-top: 20px;
  197. margin-left: 20px;
  198. .sache{
  199. margin-top: 30px;
  200. padding-bottom: 10px;
  201. .el-input {
  202. width: 20%;
  203. }
  204. }
  205. }
  206. </style>