requirement.vue 7.2 KB

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