addSalePlan.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <!-- 添加销售计划 -->
  3. <div class="addSalePlan">
  4. <PageTitle>新增</PageTitle>
  5. <div class="form-box" style="margin-right: 10rem">
  6. <dil-form :formId="281" v-model="form1" ref="from1"></dil-form>
  7. </div>
  8. <div class="table_form">
  9. <div class="materialId">
  10. <span class="text"> 物资: </span>
  11. <el-button type="primary" class="btn" @click="table = true"
  12. >浏览</el-button
  13. >
  14. </div>
  15. </div>
  16. <div class="selectionTable">
  17. <el-table
  18. :data="selectionList"
  19. border
  20. style="width: 100%"
  21. highlight-current-row
  22. >
  23. <el-table-column type="index" width="50" label="序号" align="center">
  24. </el-table-column>
  25. <el-table-column
  26. v-for="(item, i) in tableTop"
  27. :key="i"
  28. :prop="item.prop"
  29. :label="item.label"
  30. align="center"
  31. show-overflow-tooltip
  32. >
  33. <template slot="scope" v-if="item.th_name !== '件数'">
  34. <span>{{ item.label }}</span>
  35. </template>
  36. <!-- 插入输入框 -->
  37. <template slot-scope="scope">
  38. <template v-if="item.slot">
  39. <template v-if="item.prop == 'orderPlanWeight'">
  40. <el-input v-model.number="scope.row.orderPlanWeight"></el-input>
  41. </template>
  42. </template>
  43. <template v-else>
  44. <span>{{ scope.row[item.prop] }}</span>
  45. </template>
  46. </template>
  47. </el-table-column>
  48. </el-table>
  49. </div>
  50. <el-drawer
  51. title="选择物资信息"
  52. :visible.sync="table"
  53. direction="rtl"
  54. size="50%"
  55. :show-close="false"
  56. >
  57. <el-input placeholder="请输入内容" v-model="input" clearable> </el-input
  58. ><el-button type="primary" class="btn" @click="onclick">
  59. <i class="el-icon-search"></i>查询
  60. </el-button>
  61. <el-button @click="open">取消</el-button>
  62. <el-button type="primary" @click="makeSure1(2)">确定</el-button>
  63. <div class="tablecls">
  64. <!-- 查询所有的物资 -->
  65. <dilTable v-bind.sync="option" @selection-change="selectionChange">
  66. </dilTable>
  67. </div>
  68. </el-drawer>
  69. <div class="button-box">
  70. <el-button @click="cancel">取消</el-button>
  71. <el-button type="primary" @click="makeSure">确定</el-button>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import PageTitle from "@/components/Page/Title";
  77. export default {
  78. components: { PageTitle },
  79. data() {
  80. return {
  81. input: "",
  82. table: false,
  83. form1: {},
  84. value: undefined,
  85. option: {
  86. // 表格请求数据的地址
  87. requestUrl: "/api/v1/ams/getAllSteelMaterialMes?apiId=232",
  88. // 控制显示多选列
  89. selectionType: "select",
  90. },
  91. selectionList: [],
  92. selectionList1: [],
  93. tableTop: [
  94. {
  95. prop: "materialCode",
  96. label: "物资编码",
  97. width: "140",
  98. },
  99. {
  100. prop: "materialName",
  101. label: "物资名称",
  102. width: "140",
  103. },
  104. {
  105. prop: "Specification",
  106. label: "规格型号",
  107. width: "140",
  108. },
  109. {
  110. prop: "orderPlanWeight",
  111. label: "件数",
  112. slot: true,
  113. },
  114. ],
  115. };
  116. },
  117. methods: {
  118. open() {
  119. if (this.selectionList1.length != 0) {
  120. this.$confirm("取消会将已选择的数据清空, 是否继续?", "提示", {
  121. confirmButtonText: "确定",
  122. cancelButtonText: "取消",
  123. type: "warning",
  124. })
  125. .then(() => {
  126. this.selectionList1 = [];
  127. this.table = false;
  128. })
  129. .catch(() => {});
  130. } else {
  131. this.table = false;
  132. }
  133. },
  134. // 返回选中的物资信息
  135. selectionChange(selection) {
  136. this.selectionList1 = [];
  137. this.selectionList1 = selection;
  138. },
  139. // 返回主界面
  140. makeSure1() {
  141. this.selectionList1.forEach((e) => {
  142. this.selectionList.push(e);
  143. });
  144. this.selectionList1 = [];
  145. this.table = false;
  146. },
  147. // 框计算
  148. onclick() {
  149. this.option.requestUrl =
  150. "/api/v1/ams/getAllSteelMaterialMes?apiId=232&con=" + this.input;
  151. },
  152. // 确定
  153. makeSure() {
  154. // 判断是否为空的状态值(1为空,0为有值)
  155. let state = 0;
  156. if (
  157. sjTime(this.form1.planDate) &&
  158. this.form1.saleAreaId &&
  159. this.form1.insertUsername &&
  160. sjTime(this.form1.insertTime) &&
  161. this.form1.insertUpdateRemark
  162. ) {
  163. this.selectionList.forEach((e) => {
  164. if (!e.orderPlanWeight) {
  165. state = 1;
  166. return;
  167. }
  168. });
  169. } else {
  170. state = 1;
  171. }
  172. // 提示
  173. if (state == 1) {
  174. this.$message.error("不能存在空值!");
  175. }
  176. // 请求添加
  177. if (state == 0) {
  178. let amsSalePlan = {
  179. planDate: sjTime(this.form1.planDate),
  180. saleAreaId: this.form1.saleAreaId,
  181. insertUsername: this.form1.insertUsername,
  182. insertTime: sjTime(this.form1.insertTime),
  183. insertUpdateRemark: this.form1.insertUpdateRemark,
  184. };
  185. let map = {
  186. amsSalePlan: amsSalePlan,
  187. selectionList: this.selectionList,
  188. };
  189. // 掉用后端请求
  190. this.axios.post("/api/v1/ams/addAmsSalePlan", map).then((res) => {
  191. if (res.data.code == "200") {
  192. this.$router.go(-1);
  193. }
  194. });
  195. }
  196. },
  197. // 取消
  198. cancel() {
  199. this.$router.go(-1);
  200. },
  201. },
  202. };
  203. </script>
  204. <style lang='scss' scoped>
  205. </style>