requirement.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. //记录旧的row对象(未下发)
  71. oldRow: "",
  72. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  73. oldRowCount: 1,
  74. //记录旧的row对象(已下发)
  75. oldRow1: "",
  76. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(已下发)
  77. oldRowCount1: 1,
  78. tableHead: [
  79. {
  80. prop: "materialName",
  81. label: "物资名称",
  82. width: 150,
  83. },
  84. {
  85. prop:"loadName",
  86. label:"装货点",
  87. width:150
  88. },
  89. {
  90. prop:"unloadName",
  91. label:"卸货点",
  92. width:150
  93. },
  94. {
  95. prop: "materialWeight",
  96. label: "物资重量",
  97. width: 150,
  98. },
  99. {
  100. prop: "materialCount",
  101. label: "物资数量",
  102. width: 150,
  103. },
  104. ],
  105. tableData: [],
  106. tableData1: [
  107. {
  108. materialCount : 100
  109. }
  110. ],
  111. activeName: "first",
  112. };
  113. },
  114. created(){
  115. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode") == "zidonghuabu"){
  116. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0"
  117. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1"
  118. }else{
  119. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&orgCode=" + getCookie("orgCode")
  120. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&orgCode=" + getCookie("orgCode")
  121. }
  122. },
  123. methods: {
  124. //查看需求下面的运单
  125. getRequirementOrder(scope){
  126. this.$router.push(
  127. "/getRequirementOrder/" + scope.row.requirementId
  128. );
  129. },
  130. handleClick(tab, event) {
  131. this.getRequestUrl()
  132. },
  133. getRequestUrl(){
  134. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode") == "zidonghuabu"){
  135. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&i=" + new Date()
  136. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&i=" + new Date()
  137. }else{
  138. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&orgCode=" + getCookie("orgCode") + "&i=" + new Date()
  139. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&orgCode=" + getCookie("orgCode") + "&i=" + new Date()
  140. }
  141. },
  142. selectionChange(selection) {
  143. this.first.mapList = selection;
  144. },
  145. toInsert2() {
  146. this.$router.push("/addRequirement2");
  147. },
  148. updateRequirement(scope) {
  149. this.$router.push(
  150. "/updateRequirement/" + scope.row.requirementId
  151. );
  152. },
  153. deleteRequirement(scope) {
  154. this.$confirm("是否删除", "提示", {
  155. confirmButtonText: "确定",
  156. cancelButtonText: "取消",
  157. type: "warning",
  158. center: true,
  159. })
  160. .then(() => {
  161. this.axios
  162. .post(
  163. "/api/v1/ams/deleteTruckRequirement/" + scope.row.requirementId
  164. )
  165. .then((res) => {
  166. if (res.data.code == 200) {
  167. this.$message({
  168. type: "success",
  169. message: "删除成功!",
  170. });
  171. this.getRequestUrl()
  172. } else {
  173. this.$message({
  174. message: "删除失败",
  175. type: "warning",
  176. });
  177. }
  178. });
  179. })
  180. .catch(() => {
  181. this.$message({
  182. type: "info",
  183. message: "删除操作已取消!",
  184. });
  185. });
  186. },
  187. Issue() {
  188. console.log(this.first.mapList);
  189. if(this.first.mapList.length == 0){
  190. this.$message.warning("请选择需求")
  191. return
  192. }
  193. // 权限控制,判断用户是否属于轧钢厂下面的车间
  194. this.$confirm("是否下发", "提示", {
  195. confirmButtonText: "确定",
  196. cancelButtonText: "取消",
  197. type: "warning",
  198. center: true,
  199. })
  200. .then(() => {
  201. this.axios
  202. .post("/api/v1/ams/downRequirement", this.first.mapList)
  203. .then((res) => {
  204. if (res.data.code == 200) {
  205. this.$message({
  206. type: "success",
  207. message: "下发成功!",
  208. });
  209. this.getRequestUrl()
  210. this.activeName = 'second'
  211. } else {
  212. this.$message({
  213. message: "下发失败",
  214. type: "warning",
  215. });
  216. }
  217. });
  218. })
  219. .catch(() => {
  220. this.$message({
  221. type: "info",
  222. message: "取消下发!",
  223. });
  224. });
  225. },
  226. },
  227. };
  228. </script>
  229. <style lang="scss" scoped>
  230. .inwardRequirement{
  231. margin-top: 20px;
  232. margin-left: 20px;
  233. .sache{
  234. margin-top: 30px;
  235. padding-bottom: 10px;
  236. .el-input {
  237. width: 20%;
  238. }
  239. }
  240. }
  241. </style>