spareInfo.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <el-form ref="spareInfoRef">
  3. <headerTitle :title="title" style="margin-top: 15px"></headerTitle>
  4. <ele-pro-table
  5. ref="table"
  6. :columns="columns"
  7. :datasource="tableList"
  8. row-key="id"
  9. height="30vh"
  10. :needPage="false"
  11. >
  12. <template v-slot:toolbar v-if="types != 'view'">
  13. <div class="add-product" @click="addEquipment">
  14. <i class="el-icon-circle-plus-outline"></i>
  15. </div>
  16. </template>
  17. <template v-slot:totalCount="{ row, $index }">
  18. <el-input
  19. type="number"
  20. placeholder="请输入"
  21. v-model="row.totalCount"
  22. @input="handleInput(row, $index)"
  23. min="0"
  24. :disabled="types == 'view'"
  25. />
  26. </template>
  27. <template v-slot:singlePrice="{ row, $index }">
  28. <el-input
  29. type="number"
  30. placeholder="请输入"
  31. v-model="row.singlePrice"
  32. @input="handleInput(row, $index)"
  33. min="0"
  34. :disabled="types == 'view'"
  35. />
  36. </template>
  37. <template v-slot:action="{ row,$index }">
  38. <el-popconfirm
  39. v-if="types != 'view'"
  40. class="ele-action"
  41. title="确定要删除吗?"
  42. @confirm="del(row.id,$index)"
  43. >
  44. <template v-slot:reference>
  45. <el-link type="danger" :underline="false" icon="el-icon-delete">删除</el-link>
  46. </template>
  47. </el-popconfirm>
  48. </template>
  49. </ele-pro-table>
  50. <AssetsDialog ref="selectStockLedgerDialogRef" :assetType="6" @choose="confirmChoose"></AssetsDialog>
  51. </el-form>
  52. </template>
  53. <script>
  54. import AssetsDialog from '../../components/AssetsDialog.vue';
  55. // import { parameterGetByCode } from '@/api/main/index.js';
  56. export default {
  57. components: {
  58. AssetsDialog
  59. },
  60. props: {
  61. detailList: {
  62. type: Array,
  63. default: () => []
  64. },
  65. types: {
  66. type: String,
  67. default: ''
  68. },
  69. title: {
  70. type: String,
  71. default: '配件信息'
  72. }
  73. },
  74. watch: {
  75. detailList: {
  76. handler(newVal) {
  77. this.tableList = newVal;
  78. },
  79. immediate: true
  80. }
  81. },
  82. data() {
  83. return {
  84. tableList: [],
  85. columns: [
  86. {
  87. columnKey: 'index',
  88. label: '序号',
  89. type: 'index',
  90. width: 55,
  91. align: 'center',
  92. showOverflowTooltip: true,
  93. fixed: 'left'
  94. },
  95. {
  96. prop: 'categoryCode',
  97. label: '物品编码',
  98. align: 'center'
  99. },
  100. {
  101. prop: 'categoryName',
  102. label: '物品名称',
  103. align: 'center'
  104. },
  105. {
  106. prop: 'categoryModel',
  107. label: '型号',
  108. align: 'center'
  109. },
  110. {
  111. prop: 'specification',
  112. label: '规格',
  113. align: 'center'
  114. },
  115. {
  116. prop: 'level',
  117. label: '级别',
  118. align: 'center'
  119. },
  120. {
  121. prop: 'totalCount',
  122. label: '数量',
  123. align: 'center',
  124. width: 100,
  125. slot: 'totalCount'
  126. },
  127. {
  128. prop: 'singlePrice',
  129. label: '单价',
  130. align: 'center',
  131. width: 100,
  132. slot: 'singlePrice'
  133. },
  134. {
  135. prop: 'totalPrice',
  136. label: '总价',
  137. align: 'center',
  138. width: 100
  139. },
  140. // {
  141. // prop: 'measureQuantity',
  142. // label: '库存',
  143. // align: 'center'
  144. // },
  145. {
  146. prop: 'measureUnit',
  147. label: '计量单位',
  148. align: 'center'
  149. },
  150. {
  151. prop: 'warehouseName',
  152. label: '仓库',
  153. align: 'center'
  154. },
  155. {
  156. columnKey: 'action',
  157. label: '操作',
  158. width: 140,
  159. align: 'center',
  160. resizable: false,
  161. fixed: 'right',
  162. slot: 'action',
  163. showOverflowTooltip: true,
  164. show: this.types != 'view'
  165. }
  166. ]
  167. };
  168. },
  169. mounted() {
  170. this.tableList = this.detailList;
  171. },
  172. methods: {
  173. // 出库数量限制
  174. handleInput(row, index) {
  175. if (row.singlePrice == 0) {
  176. this.$set(this.tableList[index], 'totalPrice', 0);
  177. } else {
  178. this.$set(
  179. this.tableList[index],
  180. 'totalPrice',
  181. Number(row.singlePrice) * Number(row.totalCount)
  182. );
  183. }
  184. },
  185. del(id, index) {
  186. console.log(index,'index')
  187. console.log(this.tableList, 'this.tableList');
  188. // this.tableList = this.tableList.filter((item) => item.id != id);
  189. this.tableList.splice(index, 1);
  190. },
  191. async addEquipment() {
  192. // const res = await parameterGetByCode({
  193. // code: 'after_sales_accessory_source'
  194. // });
  195. // 配件回收清单进来的时候需要 查主数据
  196. if (this.title == '配件回收清单') {
  197. this.$refs.selectStockLedgerDialogRef.open(this.tableList, '1');
  198. } else {
  199. this.$refs.selectStockLedgerDialogRef.open(this.tableList, '0');
  200. }
  201. },
  202. confirmChoose(data) {
  203. data.map((item) => {
  204. item.singlePrice = item.unitPrice;
  205. delete item.id;
  206. return {
  207. ...item
  208. };
  209. });
  210. this.tableList = JSON.parse(JSON.stringify(data));
  211. },
  212. getSpareData() {
  213. return this.tableList;
  214. }
  215. }
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. .add-product {
  220. width: 100%;
  221. display: flex;
  222. align-items: center;
  223. // justify-content: flex-end;
  224. font-size: 30px;
  225. color: #1890ff;
  226. margin: 10px 0;
  227. cursor: pointer;
  228. }
  229. </style>