souvenirList.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <div>
  3. <el-form ref="form">
  4. <!-- 数据表格 -->
  5. <ele-pro-table
  6. ref="table"
  7. :columns="columns"
  8. :datasource="tableList"
  9. :needPage="false"
  10. :minHeight="100"
  11. tool-class="ele-toolbar-form"
  12. cache-key="eomContactPageTable"
  13. :summary-method="getSummaries"
  14. show-summary
  15. >
  16. <!-- 表头工具栏 -->
  17. <template v-slot:toolbar>
  18. <div class="listToolbar">
  19. <el-button
  20. v-if="dialogType !== 'view'"
  21. size="small"
  22. type="primary"
  23. icon="el-icon-plus"
  24. class="ele-btn-icon"
  25. @click="handleAddInfo"
  26. >
  27. 新增
  28. </el-button>
  29. </div>
  30. </template>
  31. <template v-slot:action="{ row, $index }" v-if="dialogType !== 'view'">
  32. <el-popconfirm
  33. class="ele-action"
  34. title="确定要删除此信息吗?"
  35. @confirm="handleDelInfo($index)"
  36. >
  37. <template v-slot:reference>
  38. <el-link type="danger" :underline="false" icon="el-icon-delete">
  39. 删除
  40. </el-link>
  41. </template>
  42. </el-popconfirm>
  43. </template>
  44. <template v-slot:dataTime="{ row, $index }" v-if="dialogType !== 'view'">
  45. <el-form-item :prop="'tableList.' + $index + '.dataTime'">
  46. <el-date-picker
  47. v-model="row.dataTime"
  48. type="date"
  49. placeholder="选择日期"
  50. value-format="yyyy-MM-dd"
  51. >
  52. </el-date-picker>
  53. </el-form-item>
  54. </template>
  55. <template v-slot:cost="{ row, $index }" v-if="dialogType !== 'view'">
  56. <el-form-item :prop="'datasource.' + $index + '.cost'">
  57. <el-input type="number" v-model="row.cost"></el-input>
  58. </el-form-item>
  59. </template>
  60. <template
  61. v-slot:personal="{ row, $index }"
  62. v-if="dialogType !== 'view'"
  63. >
  64. <el-form-item :prop="'datasource.' + $index + '.personal'">
  65. <el-input v-model="row.personal"></el-input>
  66. </el-form-item>
  67. </template>
  68. <template v-slot:place="{ row, $index }" v-if="dialogType !== 'view'">
  69. <el-form-item :prop="'datasource.' + $index + '.place'">
  70. <el-input v-model="row.place"></el-input>
  71. </el-form-item>
  72. </template>
  73. <template
  74. v-slot:materialName="{ row, $index }"
  75. v-if="dialogType !== 'view'"
  76. >
  77. <el-form-item :prop="'datasource.' + $index + '.materialName'">
  78. <el-input v-model="row.materialName">
  79. <template slot="append">
  80. <el-link
  81. type="primary"
  82. :underline="false"
  83. @click.native="materialOpen(row, $index)"
  84. >
  85. 选择</el-link
  86. >
  87. </template>
  88. </el-input>
  89. </el-form-item>
  90. </template>
  91. <template
  92. v-slot:materialNum="{ row, $index }"
  93. v-if="dialogType !== 'view'"
  94. >
  95. <el-form-item :prop="'datasource.' + $index + '.materialNum'">
  96. <el-input type="number" v-model="row.materialNum"></el-input>
  97. </el-form-item>
  98. </template>
  99. <template
  100. v-slot:ownershipId="{ row, $index }"
  101. v-if="dialogType !== 'view'"
  102. >
  103. <el-form-item :prop="'datasource.' + $index + '.ownershipId'">
  104. <el-cascader
  105. class="ele-block"
  106. :options="organizationList"
  107. placeholder="请选择"
  108. :props="defaultProps"
  109. ref="deptRef"
  110. :show-all-levels="false"
  111. v-model="row.ownershipId"
  112. @change="ownershipChange($index)"
  113. clearable
  114. ></el-cascader>
  115. </el-form-item>
  116. </template>
  117. <template v-slot:remark="{ row, $index }" v-if="dialogType !== 'view'">
  118. <el-form-item :prop="'datasource.' + $index + '.remark'">
  119. <el-input type="textarea" v-model="row.remark"></el-input>
  120. </el-form-item>
  121. </template>
  122. <template v-slot:unit="{ row, $index }" v-if="dialogType !== 'view'">
  123. <el-form-item :prop="'datasource.' + $index + '.unit'">
  124. <DictSelection
  125. dictName="计量单位"
  126. clearable
  127. v-model="row.unit"
  128. >
  129. </DictSelection>
  130. </el-form-item>
  131. </template>
  132. </ele-pro-table>
  133. </el-form>
  134. <productList
  135. :currentIndex="-1"
  136. @changeParent="changeParent"
  137. ref="productListRef"
  138. ></productList>
  139. </div>
  140. </template>
  141. <script>
  142. import { getSummaries } from '@/utils/util.js';
  143. import productList from '@/BIZComponents/product-list.vue';
  144. export default {
  145. name: 'relatedInfoTable',
  146. props: {
  147. dialogType: '',
  148. organizationList: {
  149. type: Array,
  150. default: () => {
  151. return [];
  152. }
  153. }
  154. },
  155. components: { productList },
  156. data() {
  157. return {
  158. tableList: [],
  159. currentIndex: '',
  160. defaultProps: {
  161. multiple: false,
  162. checkStrictly: true,
  163. emitPath: false,
  164. children: 'children',
  165. value: 'id',
  166. label: 'name'
  167. }
  168. };
  169. },
  170. computed: {
  171. columns() {
  172. return [
  173. {
  174. columnKey: 'index',
  175. label: '序号',
  176. type: 'index',
  177. width: 55,
  178. align: 'center',
  179. showOverflowTooltip: true,
  180. fixed: 'left'
  181. },
  182. {
  183. prop: 'dataTime',
  184. label: '日期',
  185. align: 'center',
  186. showOverflowTooltip: true,
  187. minWidth: 150,
  188. slot: 'dataTime'
  189. },
  190. {
  191. prop: 'personal',
  192. label: '领用人',
  193. align: 'center',
  194. showOverflowTooltip: true,
  195. width: 120,
  196. slot: 'personal'
  197. },
  198. {
  199. prop: 'materialName',
  200. label: '物料名称',
  201. align: 'center',
  202. showOverflowTooltip: true,
  203. minWidth: 200,
  204. slot: 'materialName'
  205. },
  206. {
  207. prop: 'materialNum',
  208. label: '数量',
  209. align: 'center',
  210. showOverflowTooltip: true,
  211. width: 100,
  212. slot: 'materialNum'
  213. },
  214. {
  215. prop: 'unit',
  216. label: '单位',
  217. align: 'center',
  218. showOverflowTooltip: true,
  219. minWidth: 100,
  220. slot: 'unit'
  221. },
  222. {
  223. prop: 'ownershipName',
  224. label: '权属单位',
  225. align: 'center',
  226. showOverflowTooltip: true,
  227. minWidth: 200,
  228. slot: 'ownershipId'
  229. },
  230. {
  231. prop: 'cost',
  232. label: '预计费用',
  233. align: 'center',
  234. showOverflowTooltip: true,
  235. minWidth: 120,
  236. slot: 'cost'
  237. },
  238. {
  239. prop: 'remark',
  240. label: '备注',
  241. minWidth: 200,
  242. align: 'center',
  243. showOverflowTooltip: true,
  244. slot: 'remark'
  245. },
  246. {
  247. columnKey: 'action',
  248. slot: 'action',
  249. label: '操作',
  250. resizable: false,
  251. width: 80,
  252. align: 'center',
  253. showOverflowTooltip: true,
  254. fixed: 'right'
  255. }
  256. ];
  257. }
  258. },
  259. mounted() {},
  260. methods: {
  261. getSummaries(param) {
  262. return getSummaries(param, 'cost');
  263. },
  264. //删除任务信息数据
  265. handleDelInfo(index) {
  266. this.tableList.splice(index, 1);
  267. },
  268. //修改回显
  269. putTableValue(data) {
  270. this.tableList = data || [];
  271. },
  272. getTableValue() {
  273. return this.tableList;
  274. },
  275. materialOpen(row, index) {
  276. this.currentIndex = index;
  277. this.$refs.productListRef.open(row, index);
  278. },
  279. changeParent(list) {
  280. if (list.length > 0) {
  281. this.$set(
  282. this.tableList[this.currentIndex],
  283. 'materialName',
  284. list[0].name
  285. );
  286. this.$set(this.tableList[this.currentIndex], 'materialId', list[0].id);
  287. }
  288. },
  289. ownershipChange(index) {
  290. this.$nextTick(()=>{
  291. const data =this.$refs.deptRef.getCheckedNodes()
  292. this.$set(this.tableList[index], 'ownershipName', data[0].label);
  293. })
  294. },
  295. handleAddInfo() {
  296. this.tableList.push({
  297. dataTime: '',
  298. personal: '',
  299. place: '',
  300. materialName: '',
  301. materialId: '',
  302. materialNum: '',
  303. ownershipId: '',
  304. ownershipName: '',
  305. remark: '',
  306. cost: ''
  307. });
  308. }
  309. }
  310. };
  311. </script>
  312. <style scoped lang="scss">
  313. :deep(.el-form-item) {
  314. margin-bottom: 0;
  315. }
  316. .listToolbar {
  317. display: flex;
  318. justify-content: space-between;
  319. align-items: center;
  320. }
  321. </style>