requirement.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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="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="getRequirementMaterial1(scope.row)"
  38. >
  39. 物资详情
  40. </el-button>
  41. <el-button
  42. type="text"
  43. size="mini"
  44. @click="deleteRequirement(scope)"
  45. >
  46. 删除
  47. </el-button>
  48. </template>
  49. </el-table-column>
  50. <!-- 物资详情抽屉 -->
  51. <el-table-column type="expand" width="1">
  52. <template slot-scope="props">
  53. <el-form label-position="center" inline class="demo-table-expand">
  54. <div v-if="false">{{ props }}</div>
  55. <div>
  56. <el-table :data="tableData1" border >
  57. <el-table-column
  58. v-for="(item, i) in tableHead"
  59. :key="i"
  60. :prop="item.prop"
  61. :label="item.label"
  62. :width="item.width"
  63. ></el-table-column>
  64. </el-table>
  65. </div>
  66. </el-form>
  67. </template>
  68. </el-table-column>
  69. </dilTable>
  70. </el-tab-pane>
  71. <el-tab-pane label="已下发" name="second">
  72. <dilTable v-bind.sync="second" ref="table">
  73. <el-table-column fixed="right" label="操作" width="80">
  74. <template slot-scope="scope">
  75. <el-button
  76. type="text"
  77. size="mini"
  78. @click="getRequirementMaterial(scope.row)"
  79. >
  80. 物资详情
  81. </el-button>
  82. </template>
  83. </el-table-column>
  84. <!-- 物资详情抽屉 -->
  85. <el-table-column type="expand" width="1">
  86. <template slot-scope="props">
  87. <el-form label-position="center" inline class="demo-table-expand">
  88. <div v-if="false">{{ props }}</div>
  89. <div>
  90. <el-table :data="tableData" border >
  91. <el-table-column
  92. v-for="(item, i) in tableHead"
  93. :key="i"
  94. :prop="item.prop"
  95. :label="item.label"
  96. :width="item.width"
  97. ></el-table-column>
  98. </el-table>
  99. </div>
  100. </el-form>
  101. </template>
  102. </el-table-column>
  103. </dilTable>
  104. </el-tab-pane>
  105. </el-tabs>
  106. </div>
  107. </template>
  108. </div>
  109. </template>
  110. <script>
  111. import { getCookie } from "@/utils/util.js";
  112. export default {
  113. data() {
  114. return {
  115. inputText: "",
  116. first: {
  117. // first请求数据的地址
  118. requestUrl:
  119. "",
  120. selectionType: "select",
  121. mapList: [],
  122. },
  123. second: {
  124. // second请求数据的地址
  125. requestUrl:
  126. "",
  127. },
  128. //记录旧的row对象(未下发)
  129. oldRow: "",
  130. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(未下发)
  131. oldRowCount: 1,
  132. //记录旧的row对象(已下发)
  133. oldRow1: "",
  134. //记录上一个展开的点击次数,单数为展开状态,复数为闭合状态(已下发)
  135. oldRowCount1: 1,
  136. tableHead: [
  137. {
  138. prop: "materialName",
  139. label: "物资名称",
  140. width: 150,
  141. },
  142. {
  143. prop:"loadName",
  144. label:"装货点",
  145. width:150
  146. },
  147. {
  148. prop:"unloadName",
  149. label:"卸货点",
  150. width:150
  151. },
  152. {
  153. prop: "materialWeight",
  154. label: "物资重量",
  155. width: 150,
  156. },
  157. {
  158. prop: "materialCount",
  159. label: "物资数量",
  160. width: 150,
  161. },
  162. ],
  163. tableData: [],
  164. tableData1: [
  165. {
  166. materialCount : 100
  167. }
  168. ],
  169. activeName: "first",
  170. };
  171. },
  172. created(){
  173. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode") == "zidonghuabu"){
  174. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0"
  175. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1"
  176. }else{
  177. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&orgCode=" + getCookie("orgCode")
  178. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&orgCode=" + getCookie("orgCode")
  179. }
  180. },
  181. methods: {
  182. getRequirementMaterial(row) {
  183. // 记录重复点击次数
  184. if (this.oldRow === row) {
  185. this.oldRowCount += 1;
  186. }
  187. // 切换当前详情表
  188. this.$refs.table.toggleRowExpansion(row);
  189. // 打开前关闭上一个详情表
  190. if (this.oldRow != "") {
  191. if (this.oldRow != row) {
  192. if (this.oldRowCount % 2 === 1) {
  193. this.$refs.table.toggleRowExpansion(this.oldRow);
  194. } else {
  195. this.oldRowCount = 1;
  196. }
  197. } else {
  198. this.oldRow = null;
  199. return;
  200. }
  201. }
  202. // 重置上一个点击对象
  203. this.oldRow = row;
  204. this.getMaterial(row.requirementId);
  205. },
  206. getRequirementMaterial1(row) {
  207. // 记录重复点击次数
  208. if (this.oldRow1 === row) {
  209. this.oldRowCount1 += 1;
  210. }
  211. // 切换当前详情表
  212. this.$refs.table1.toggleRowExpansion(row);
  213. // 打开前关闭上一个详情表
  214. if (this.oldRow1 != "") {
  215. if (this.oldRow1 != row) {
  216. if (this.oldRowCount1 % 2 === 1) {
  217. this.$refs.table1.toggleRowExpansion(this.oldRow1);
  218. } else {
  219. this.oldRowCount1 = 1;
  220. }
  221. } else {
  222. this.oldRow1 = null;
  223. return;
  224. }
  225. }
  226. // 重置上一个点击对象
  227. this.oldRow1 = row;
  228. this.getMaterial(row.requirementId);
  229. },
  230. handleClick(tab, event) {
  231. this.getRequestUrl()
  232. this.getRequirementMaterial()
  233. },
  234. getMaterial(requirementId){
  235. console.log(requirementId)
  236. this.axios.post("/api/v1/ams/getRequirementMaterial/" + requirementId).then((res) => {
  237. this.tableData = res.data.data
  238. this.tableData1 = res.data.data
  239. console.log(res.data.data)
  240. })
  241. },
  242. getRequestUrl(){
  243. if(getCookie("orgCode") == "dagangadmin"||getCookie("orgCode") == "zidonghuabu"){
  244. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&i=" + new Date()
  245. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&i=" + new Date()
  246. }else{
  247. this.first.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=0&orgCode=" + getCookie("orgCode") + "&i=" + new Date()
  248. this.second.requestUrl = "/api/v1/ams/getTruckRequirementList?apiId=207&requirementStatus=1&orgCode=" + getCookie("orgCode") + "&i=" + new Date()
  249. }
  250. },
  251. selectionChange(selection) {
  252. this.first.mapList = selection;
  253. },
  254. toInsert2() {
  255. this.$router.push("/addRequirement2");
  256. },
  257. updateRequirement(scope) {
  258. this.$router.push(
  259. "/updateRequirement/" + scope.row.requirementId
  260. );
  261. },
  262. deleteRequirement(scope) {
  263. this.$confirm("是否删除", "提示", {
  264. confirmButtonText: "确定",
  265. cancelButtonText: "取消",
  266. type: "warning",
  267. center: true,
  268. })
  269. .then(() => {
  270. this.axios
  271. .post(
  272. "/api/v1/ams/deleteTruckRequirement/" + scope.row.requirementId
  273. )
  274. .then((res) => {
  275. if (res.data.code == 200) {
  276. this.$message({
  277. type: "success",
  278. message: "删除成功!",
  279. });
  280. this.getRequestUrl()
  281. } else {
  282. this.$message({
  283. message: "删除失败",
  284. type: "warning",
  285. });
  286. }
  287. });
  288. })
  289. .catch(() => {
  290. this.$message({
  291. type: "info",
  292. message: "删除操作已取消!",
  293. });
  294. });
  295. },
  296. Issue() {
  297. console.log(this.first.mapList);
  298. if(this.first.mapList.length == 0){
  299. this.$message.warning("请选择需求")
  300. return
  301. }
  302. this.$confirm("是否下发", "提示", {
  303. confirmButtonText: "确定",
  304. cancelButtonText: "取消",
  305. type: "warning",
  306. center: true,
  307. })
  308. .then(() => {
  309. this.axios
  310. .post("/api/v1/ams/downRequirement", this.first.mapList)
  311. .then((res) => {
  312. if (res.data.code == 200) {
  313. this.$message({
  314. type: "success",
  315. message: "下发成功!",
  316. });
  317. this.getRequestUrl()
  318. this.activeName = 'second'
  319. } else {
  320. this.$message({
  321. message: "下发失败",
  322. type: "warning",
  323. });
  324. }
  325. });
  326. })
  327. .catch(() => {
  328. this.$message({
  329. type: "info",
  330. message: "取消下发!",
  331. });
  332. });
  333. },
  334. },
  335. };
  336. </script>
  337. <style lang="scss">
  338. .steel_inbound{
  339. .sache{
  340. padding: 1.25rem 0.375rem;
  341. .el-input {
  342. width: 20%;
  343. margin-right: 1.25rem;
  344. }
  345. }
  346. }
  347. </style>