visitList.vue 8.9 KB

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