requirement.vue 7.2 KB

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