add.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <div>
  3. <el-button size="mini" type="primary" @click="addBtn">{{
  4. $t("添 加")
  5. }}</el-button>
  6. <el-drawer append-to-body :visible.sync="dialogFormVisible" size="70%">
  7. <div slot="title" style="font-size: 15px">{{$t('添加商品')}}</div>
  8. <div class="drawer__panel">
  9. <el-input
  10. style="width: 250px; margin-bottom: 10px"
  11. size="small"
  12. :placeholder="$t('请输入搜索内容')"
  13. clearable
  14. @clear="getOrderList((params.content.pageNumber = 1))"
  15. v-model="params.content.where.condition"
  16. @keyup.enter.native="getOrderList((params.content.pageNumber = 1))"
  17. ></el-input>
  18. <selectTable
  19. @selectChange="selectChange"
  20. v-if="dialogFormVisible"
  21. idName="itemid"
  22. ref="table"
  23. v-model="result"
  24. :layout="tablecols"
  25. :data="orderList"
  26. :custom="true"
  27. height="500px"
  28. @upDateData="upDateData"
  29. >
  30. <template v-slot:customcol="scope">
  31. <div>{{ $t(scope.column.data[scope.column.columnname]) }}</div>
  32. </template>
  33. </selectTable>
  34. <div class="container normal-panel" style="text-align: right">
  35. <el-pagination
  36. style="text-align: right"
  37. background
  38. small
  39. @size-change="handleSizeChange"
  40. @current-change="handleCurrentChange"
  41. :current-page="params.content.pageNumber"
  42. :page-size="params.content.pageSize"
  43. layout="total, prev, pager, next, jumper"
  44. :total="total"
  45. >
  46. </el-pagination>
  47. </div>
  48. </div>
  49. <div class="fixed__btn__panel">
  50. <el-button
  51. size="small"
  52. @click="dialogFormVisible = false"
  53. class="normal-btn-width"
  54. >{{ $t("取 消") }}</el-button
  55. >
  56. <el-button
  57. size="small"
  58. type="primary"
  59. @click="onSubmit"
  60. :disabled="isLength"
  61. class="normal-btn-width"
  62. >{{ $t("确 定") }}</el-button
  63. >
  64. </div>
  65. </el-drawer>
  66. </div>
  67. </template>
  68. <script>
  69. import selectTable from "@/components/selectTable/index";
  70. import { log } from "@antv/g2plot/lib/utils";
  71. export default {
  72. name: "add",
  73. props: ["data", "disabled"],
  74. components: { selectTable },
  75. data() {
  76. return {
  77. result: [],
  78. selectArr: [],
  79. isLength: true,
  80. dialogFormVisible: false,
  81. orderList: [],
  82. tablecols: [],
  83. total: 0,
  84. params: {
  85. id: 20230206161703,
  86. content: {
  87. pageNumber: 1,
  88. pageSize: 20,
  89. sa_serviceorderid: "",
  90. sa_orderid: "",
  91. where: {
  92. condition: "",
  93. },
  94. },
  95. },
  96. };
  97. },
  98. computed: {
  99. isEdit() {
  100. return function (data) {
  101. console.log(this.selectArr.some((item) => item == data));
  102. let is = this.selectArr.some((item) => item == data);
  103. return is;
  104. };
  105. },
  106. },
  107. mounted() {
  108. this.getOrderList();
  109. },
  110. created() {
  111. this.tablecols = this.tool.tabelCol(
  112. this.$route.name
  113. ).productTable.tablecols;
  114. },
  115. watch: {
  116. dialogFormVisible(val) {
  117. if (!val) {
  118. this.$refs.table.allArr = [];
  119. }
  120. },
  121. },
  122. methods: {
  123. addBtn() {
  124. this.dialogFormVisible = true;
  125. this.getOrderList();
  126. },
  127. async onSubmit() {
  128. let data = this.$refs.table.allArr.map((item) => {
  129. return {
  130. sa_serviceorderitemsid: 0,
  131. itemid: item.itemid,
  132. reason: "",
  133. qty: 1,
  134. };
  135. });
  136. let res = await this.$api.requested({
  137. id: "20230206161803",
  138. content: {
  139. sa_serviceorderid: this.$route.query.id,
  140. iteminfos: data,
  141. },
  142. });
  143. this.tool.showMessage(res, () => {
  144. this.$emit("onSuccess");
  145. this.dialogFormVisible = false;
  146. });
  147. },
  148. async getOrderList() {
  149. this.params.content.sa_serviceorderid = this.data.sa_serviceorderid;
  150. this.params.content.sa_orderid = this.data.sa_orderid;
  151. let res = await this.$api.requested(this.params);
  152. console.log(res.data);
  153. this.orderList = res.data;
  154. this.total = res.total;
  155. console.log(res);
  156. },
  157. selectChange(data) {
  158. this.selectArr = data;
  159. this.isLength = data.length < 1;
  160. },
  161. upDateData(data) {
  162. this.selectArr = data;
  163. this.isLength = data.length < 1;
  164. },
  165. handleSizeChange(val) {
  166. // console.log(`每页 ${val} 条`);
  167. this.params.content.pageSize = val;
  168. this.getOrderList();
  169. },
  170. handleCurrentChange(val) {
  171. // console.log(`当前页: ${val}`);
  172. this.params.content.pageNumber = val;
  173. this.getOrderList();
  174. },
  175. },
  176. };
  177. </script>
  178. <style scoped>
  179. .dialog-footer {
  180. margin-top: 0;
  181. }
  182. .el-select {
  183. width: 100%;
  184. }
  185. </style>